|
10 | 10 |
|
11 | 11 | module.exports = function(context) {
|
12 | 12 |
|
13 |
| - var NOT_DEFINED_MESSAGE = '\'React\' must be in scope when using JSX'; |
14 |
| - |
15 |
| - function findVariable(variables, name) { |
16 |
| - var i, len; |
17 |
| - for (i = 0, len = variables.length; i < len; i++) { |
18 |
| - if (variables[i].name === name) { |
19 |
| - return true; |
20 |
| - } |
21 |
| - } |
22 |
| - return false; |
| 13 | + var NOT_DEFINED_MESSAGE = '\'React\' must be in scope when using JSX'; |
| 14 | + |
| 15 | + function findVariable(variables, name) { |
| 16 | + var i, len; |
| 17 | + for (i = 0, len = variables.length; i < len; i++) { |
| 18 | + if (variables[i].name === name) { |
| 19 | + return true; |
| 20 | + } |
23 | 21 | }
|
| 22 | + return false; |
| 23 | + } |
24 | 24 |
|
25 |
| - function variablesInScope() { |
26 |
| - var scope = context.getScope(), |
27 |
| - variables = scope.variables; |
| 25 | + function variablesInScope() { |
| 26 | + var scope = context.getScope(), |
| 27 | + variables = scope.variables; |
28 | 28 |
|
29 |
| - while (scope.type !== 'global') { |
30 |
| - scope = scope.upper; |
31 |
| - variables = scope.variables.concat(variables); |
32 |
| - } |
33 |
| - |
34 |
| - return variables; |
| 29 | + while (scope.type !== 'global') { |
| 30 | + scope = scope.upper; |
| 31 | + variables = scope.variables.concat(variables); |
35 | 32 | }
|
36 | 33 |
|
37 |
| - return { |
| 34 | + return variables; |
| 35 | + } |
| 36 | + |
| 37 | + return { |
38 | 38 |
|
39 |
| - 'JSXOpeningElement': function(node) { |
40 |
| - var variables = variablesInScope(); |
41 |
| - if (!findVariable(variables, 'React')) { |
42 |
| - context.report(node, NOT_DEFINED_MESSAGE); |
43 |
| - } |
44 |
| - } |
| 39 | + JSXOpeningElement: function(node) { |
| 40 | + var variables = variablesInScope(); |
| 41 | + if (!findVariable(variables, 'React')) { |
| 42 | + context.report(node, NOT_DEFINED_MESSAGE); |
| 43 | + } |
| 44 | + } |
45 | 45 |
|
46 |
| - }; |
| 46 | + }; |
47 | 47 |
|
48 | 48 | };
|
0 commit comments