@@ -32,167 +32,185 @@ eslint.defineRule('jsx-uses-vars', require('../../../lib/rules/jsx-uses-vars'));
32
32
ruleTester . run ( 'no-unused-vars' , ruleNoUnusedVars , {
33
33
valid : [
34
34
{
35
- code : '\
36
- /*eslint jsx-uses-vars:1*/\
37
- function foo() {\
38
- var App;\
39
- var bar = React.render(<App/>);\
40
- return bar;\
41
- };\
42
- foo()' ,
43
- parserOptions : parserOptions
44
- } , {
45
- code : '\
46
- /*eslint jsx-uses-vars:1*/\
47
- var App;\
48
- React.render(<App/>);' ,
49
- parserOptions : parserOptions
50
- } , {
51
- code : '\
52
- /*eslint jsx-uses-vars:1*/\
53
- var App;\
54
- React.render(<App/>);' ,
35
+ code : `
36
+ /* eslint jsx-uses-vars: 1 */
37
+ function foo() {
38
+ var App;
39
+ var bar = React.render(<App/>);
40
+ return bar;
41
+ };
42
+ foo()
43
+ ` ,
44
+ parserOptions : parserOptions
45
+ } , {
46
+ code : `
47
+ /* eslint jsx-uses-vars: 1 */
48
+ var App;
49
+ React.render(<App/>);
50
+ ` ,
51
+ parserOptions : parserOptions
52
+ } , {
53
+ code : `
54
+ /* eslint jsx-uses-vars: 1 */
55
+ var App;
56
+ React.render(<App/>);
57
+ ` ,
55
58
parser : 'babel-eslint' ,
56
59
parserOptions : parserOptions
57
60
} , {
58
- code : '\
59
- /*eslint jsx-uses-vars:1*/\
60
- var a=1;\
61
- React.render(<img src={a} />);' ,
62
- parserOptions : parserOptions
63
- } , {
64
- code : '\
65
- /*eslint jsx-uses-vars:1*/\
66
- var App;\
67
- function f() {\
68
- return <App />;\
69
- }\
70
- f();' ,
71
- parserOptions : parserOptions
72
- } , {
73
- code : '\
74
- /*eslint jsx-uses-vars:1*/\
75
- var App;\
76
- <App.Hello />' ,
77
- parserOptions : parserOptions
78
- } , {
79
- code : '\
80
- /*eslint jsx-uses-vars:1*/\
81
- var App;\
82
- <App:Hello />' ,
83
- parserOptions : parserOptions
84
- } , {
85
- code : '\
86
- /*eslint jsx-uses-vars:1*/\
87
- class HelloMessage {}\
88
- <HelloMessage />' ,
89
- parserOptions : parserOptions
90
- } , {
91
- code : '\
92
- /*eslint jsx-uses-vars:1*/\
93
- class HelloMessage {\
94
- render() {\
95
- var HelloMessage = <div>Hello</div>;\
96
- return HelloMessage;\
97
- }\
98
- }\
99
- <HelloMessage />' ,
100
- parserOptions : parserOptions
101
- } , {
102
- code : '\
103
- /*eslint jsx-uses-vars:1*/\
104
- function foo() {\
105
- var App = { Foo: { Bar: {}}};\
106
- var bar = React.render(<App.Foo.Bar/>);\
107
- return bar;\
108
- };\
109
- foo()' ,
110
- parserOptions : parserOptions
111
- } , {
112
- code : '\
113
- /*eslint jsx-uses-vars:1*/\
114
- function foo() {\
115
- var App = { Foo: { Bar: { Baz: {}}}};\
116
- var bar = React.render(<App.Foo.Bar.Baz/>);\
117
- return bar;\
118
- };\
119
- foo()' ,
61
+ code : `
62
+ /* eslint jsx-uses-vars: 1 */
63
+ var a = 1;
64
+ React.render(<img src={a} />);
65
+ ` ,
66
+ parserOptions : parserOptions
67
+ } , {
68
+ code : `
69
+ /* eslint jsx-uses-vars: 1 */
70
+ var App;
71
+ function f() {
72
+ return <App />;
73
+ }
74
+ f();
75
+ ` ,
76
+ parserOptions : parserOptions
77
+ } , {
78
+ code : `
79
+ /* eslint jsx-uses-vars: 1 */
80
+ var App;
81
+ <App.Hello />
82
+ ` ,
83
+ parserOptions : parserOptions
84
+ } , {
85
+ code : `
86
+ /* eslint jsx-uses-vars: 1 */
87
+ var App;
88
+ <App:Hello />
89
+ ` ,
90
+ parserOptions : parserOptions
91
+ } , {
92
+ code : `
93
+ /* eslint jsx-uses-vars: 1 */
94
+ class HelloMessage {}
95
+ <HelloMessage />
96
+ ` ,
97
+ parserOptions : parserOptions
98
+ } , {
99
+ code : `
100
+ /* eslint jsx-uses-vars: 1 */
101
+ class HelloMessage {
102
+ render() {
103
+ var HelloMessage = <div>Hello</div>;
104
+ return HelloMessage;
105
+ }
106
+ }
107
+ <HelloMessage />
108
+ ` ,
109
+ parserOptions : parserOptions
110
+ } , {
111
+ code : `
112
+ /* eslint jsx-uses-vars: 1 */
113
+ function foo() {
114
+ var App = { Foo: { Bar: {} } };
115
+ var bar = React.render(<App.Foo.Bar/>);
116
+ return bar;
117
+ };
118
+ foo()
119
+ ` ,
120
+ parserOptions : parserOptions
121
+ } , {
122
+ code : `
123
+ /* eslint jsx-uses-vars: 1 */
124
+ function foo() {
125
+ var App = { Foo: { Bar: { Baz: {} } } };
126
+ var bar = React.render(<App.Foo.Bar.Baz/>);
127
+ return bar;
128
+ };
129
+ foo()
130
+ ` ,
120
131
parserOptions : parserOptions
121
132
}
122
133
] ,
123
134
invalid : [
124
135
{
125
- code : '/*eslint jsx-uses-vars:1 */ var App;' ,
136
+ code : '/* eslint jsx-uses-vars: 1 */ var App;' ,
126
137
errors : [ { message : '\'App\' is defined but never used.' } ] ,
127
138
parserOptions : parserOptions
128
139
} , {
129
- code : '\
130
- /*eslint jsx-uses-vars:1*/\
131
- var App;\
132
- var unused;\
133
- React.render(<App unused=""/>);' ,
140
+ code : `
141
+ /* eslint jsx-uses-vars: 1 */
142
+ var App;
143
+ var unused;
144
+ React.render(<App unused=""/>);
145
+ ` ,
134
146
errors : [ { message : '\'unused\' is defined but never used.' } ] ,
135
147
parserOptions : parserOptions
136
148
} , {
137
- code : '\
138
- /*eslint jsx-uses-vars:1*/\
139
- var App;\
140
- var Hello;\
141
- React.render(<App:Hello/>);' ,
149
+ code : `
150
+ /* eslint jsx-uses-vars: 1 */
151
+ var App;
152
+ var Hello;
153
+ React.render(<App:Hello/>);
154
+ ` ,
142
155
errors : [ { message : '\'Hello\' is defined but never used.' } ] ,
143
156
parserOptions : parserOptions
144
157
} , {
145
- code : '\
146
- /*eslint jsx-uses-vars:1*/\
147
- var Button;\
148
- var Input;\
149
- React.render(<Button.Input unused=""/>);' ,
158
+ code : `
159
+ /* eslint jsx-uses-vars: 1 */
160
+ var Button;
161
+ var Input;
162
+ React.render(<Button.Input unused=""/>);
163
+ ` ,
150
164
errors : [ { message : '\'Input\' is defined but never used.' } ] ,
151
165
parserOptions : parserOptions
152
166
} , {
153
- code : '\
154
- /*eslint jsx-uses-vars:1*/\
155
- class unused {}' ,
167
+ code : `
168
+ /* eslint jsx-uses-vars: 1 */
169
+ class unused {}
170
+ ` ,
156
171
errors : [ { message : '\'unused\' is defined but never used.' } ] ,
157
172
parserOptions : parserOptions
158
173
} , {
159
- code : '\
160
- /*eslint jsx-uses-vars:1*/\
161
- class HelloMessage {\
162
- render() {\
163
- var HelloMessage = <div>Hello</div>;\
164
- return HelloMessage;\
165
- }\
166
- }' ,
174
+ code : `
175
+ /* eslint jsx-uses-vars: 1 */
176
+ class HelloMessage {
177
+ render() {
178
+ var HelloMessage = <div>Hello</div>;
179
+ return HelloMessage;
180
+ }
181
+ }
182
+ ` ,
167
183
errors : [ {
168
184
message : '\'HelloMessage\' is defined but never used.' ,
169
185
line : 1
170
186
} ] ,
171
187
parserOptions : parserOptions
172
188
} , {
173
- code : '\
174
- /*eslint jsx-uses-vars:1*/\
175
- class HelloMessage {\
176
- render() {\
177
- var HelloMessage = <div>Hello</div>;\
178
- return HelloMessage;\
179
- }\
180
- }' ,
189
+ code : `
190
+ /* eslint jsx-uses-vars: 1 */
191
+ class HelloMessage {
192
+ render() {
193
+ var HelloMessage = <div>Hello</div>;
194
+ return HelloMessage;
195
+ }
196
+ }
197
+ ` ,
181
198
errors : [ {
182
199
message : '\'HelloMessage\' is defined but never used.' ,
183
200
line : 1
184
201
} ] ,
185
202
parser : 'babel-eslint' ,
186
203
parserOptions : parserOptions
187
204
} , {
188
- code : '\
189
- /*eslint jsx-uses-vars:1*/\
190
- import {Hello} from \'Hello\';\
191
- function Greetings() {\
192
- const Hello = require(\'Hello\').default;\
193
- return <Hello />;\
194
- }\
195
- Greetings();' ,
205
+ code : `
206
+ /* eslint jsx-uses-vars: 1 */
207
+ import {Hello} from 'Hello';
208
+ function Greetings() {
209
+ const Hello = require('Hello').default;
210
+ return <Hello />;
211
+ }
212
+ Greetings();
213
+ ` ,
196
214
errors : [ {
197
215
message : '\'Hello\' is defined but never used.' ,
198
216
line : 1
0 commit comments