27928adec7959a22c2e077ba0d360c15ba3fb1f7
[platform/framework/web/crosswalk-tizen.git] /
1 /**
2  * @fileoverview Require spaces following return, throw, and case
3  * @author Michael Ficarra
4  */
5 "use strict";
6
7 //------------------------------------------------------------------------------
8 // Rule Definition
9 //------------------------------------------------------------------------------
10
11 module.exports = function(context) {
12
13     function check(node) {
14         var tokens = context.getFirstTokens(node, 2),
15             value = tokens[0].value;
16
17         if (tokens[0].range[1] >= tokens[1].range[0]) {
18             context.report(node, "Keyword \"" + value + "\" must be followed by whitespace.");
19         }
20     }
21
22     return {
23         "ReturnStatement": function(node) {
24             if (node.argument) {
25                 check(node);
26             }
27         },
28         "SwitchCase": function(node) {
29             if (node.test) {
30                 check(node);
31             }
32         },
33         "ThrowStatement": check
34     };
35
36 };