@@ -30,85 +30,85 @@ ruleTester.run('jsx-no-literals', rule, {
30
30
31
31
valid : [
32
32
{
33
- code : [
34
- ' class Comp1 extends Component {' ,
35
- ' render() {' ,
36
- ' return (' ,
37
- ' <div>' ,
38
- ' {\ 'asdjfl\'}' ,
39
- ' </div>' ,
40
- ' );' ,
41
- ' }' ,
42
- '}'
43
- ] . join ( '\n' ) ,
33
+ code : `
34
+ class Comp1 extends Component {
35
+ render() {
36
+ return (
37
+ <div>
38
+ {'asdjfl'}
39
+ </div>
40
+ );
41
+ }
42
+ }
43
+ ` ,
44
44
parser : 'babel-eslint'
45
45
} , {
46
- code : [
47
- ' class Comp1 extends Component {' ,
48
- ' render() {' ,
49
- ' return (<div>{\ 'test\ '}</div>);' ,
50
- ' }' ,
51
- '}'
52
- ] . join ( '\n' ) ,
46
+ code : `
47
+ class Comp1 extends Component {
48
+ render() {
49
+ return (<div>{'test'}</div>);
50
+ }
51
+ }
52
+ ` ,
53
53
parser : 'babel-eslint'
54
54
} , {
55
- code : [
56
- ' class Comp1 extends Component {' ,
57
- ' render() {' ,
58
- ' const bar = (<div>{\ 'hello\ '}</div>);' ,
59
- ' return bar;' ,
60
- ' }' ,
61
- '}'
62
- ] . join ( '\n' ) ,
55
+ code : `
56
+ class Comp1 extends Component {
57
+ render() {
58
+ const bar = (<div>{'hello'}</div>);
59
+ return bar;
60
+ }
61
+ }
62
+ ` ,
63
63
parser : 'babel-eslint'
64
64
} , {
65
- code : [
66
- ' var Hello = createReactClass({' ,
67
- ' foo: (<div>{\ 'hello\ '}</div>),' ,
68
- ' render() {' ,
69
- ' return this.foo;' ,
70
- ' },' ,
71
- ' });'
72
- ] . join ( '\n' ) ,
65
+ code : `
66
+ var Hello = createReactClass({
67
+ foo: (<div>{'hello'}</div>),
68
+ render() {
69
+ return this.foo;
70
+ },
71
+ });
72
+ ` ,
73
73
parser : 'babel-eslint'
74
74
} , {
75
- code : [
76
- ' class Comp1 extends Component {' ,
77
- ' render() {' ,
78
- ' return (' ,
79
- ' <div>' ,
80
- ' {\ 'asdjfl\'}' ,
81
- ' {\ 'test\'}' ,
82
- ' {\ 'foo\'}' ,
83
- ' </div>' ,
84
- ' );' ,
85
- ' }' ,
86
- '}'
87
- ] . join ( '\n' ) ,
75
+ code : `
76
+ class Comp1 extends Component {
77
+ render() {
78
+ return (
79
+ <div>
80
+ {'asdjfl'}
81
+ {'test'}
82
+ {'foo'}
83
+ </div>
84
+ );
85
+ }
86
+ }
87
+ ` ,
88
88
parser : 'babel-eslint'
89
89
} , {
90
- code : [
91
- ' class Comp1 extends Component {' ,
92
- ' render() {' ,
93
- ' return (' ,
94
- ' <div>' ,
95
- ' </div>' ,
96
- ' );' ,
97
- ' }' ,
98
- '}'
99
- ] . join ( '\n' ) ,
90
+ code : `
91
+ class Comp1 extends Component {
92
+ render() {
93
+ return (
94
+ <div>
95
+ </div>
96
+ );
97
+ }
98
+ }
99
+ ` ,
100
100
parser : 'babel-eslint'
101
101
} , {
102
- code : [
103
- ' var foo = require(\ 'foo\ ');'
104
- ] . join ( '\n' ) ,
102
+ code : `
103
+ var foo = require('foo');
104
+ ` ,
105
105
parser : 'babel-eslint'
106
106
} , {
107
- code : [
108
- ' <Foo bar=\ 'test\'>' ,
109
- ' {\ 'blarg\'}' ,
110
- ' </Foo>'
111
- ] . join ( '\n' ) ,
107
+ code : `
108
+ <Foo bar='test'>
109
+ {'blarg'}
110
+ </Foo>
111
+ ` ,
112
112
parser : 'babel-eslint'
113
113
} , {
114
114
code : `
@@ -156,117 +156,117 @@ ruleTester.run('jsx-no-literals', rule, {
156
156
code : '<Foo bar={{}} />' ,
157
157
options : [ { noStrings : true } ]
158
158
} , {
159
- code : [
160
- ' class Comp1 extends Component {' ,
161
- ' asdf() {}' ,
162
- ' render() {' ,
163
- ' return <Foo bar={this.asdf} />;' ,
164
- ' }' ,
165
- '}'
166
- ] . join ( '\n' ) ,
159
+ code : `
160
+ class Comp1 extends Component {
161
+ asdf() {}
162
+ render() {
163
+ return <Foo bar={this.asdf} />;
164
+ }
165
+ }
166
+ ` ,
167
167
options : [ { noStrings : true } ]
168
168
} , {
169
- code : [
170
- ' class Comp1 extends Component {' ,
171
- ' render() {' ,
172
- ' let foo = `bar`;' ,
173
- ' return <div />;' ,
174
- ' }' ,
175
- '}'
176
- ] . join ( '\n' ) ,
169
+ code : `
170
+ class Comp1 extends Component {
171
+ render() {
172
+ let foo = \ `bar\`;
173
+ return <div />;
174
+ }
175
+ }
176
+ ` ,
177
177
options : [ { noStrings : true } ]
178
178
}
179
179
180
180
] ,
181
181
182
182
invalid : [
183
183
{
184
- code : [
185
- ' class Comp1 extends Component {' ,
186
- ' render() {' ,
187
- ' return (<div>test</div>);' ,
188
- ' }' ,
189
- '}'
190
- ] . join ( '\n' ) ,
184
+ code : `
185
+ class Comp1 extends Component {
186
+ render() {
187
+ return (<div>test</div>);
188
+ }
189
+ }
190
+ ` ,
191
191
parser : 'babel-eslint' ,
192
192
errors : [ { message : 'Missing JSX expression container around literal string' } ]
193
193
} , {
194
- code : [
195
- ' class Comp1 extends Component {' ,
196
- ' render() {' ,
197
- ' const foo = (<div>test</div>);' ,
198
- ' return foo;' ,
199
- ' }' ,
200
- '}'
201
- ] . join ( '\n' ) ,
194
+ code : `
195
+ class Comp1 extends Component {
196
+ render() {
197
+ const foo = (<div>test</div>);
198
+ return foo;
199
+ }
200
+ }
201
+ ` ,
202
202
parser : 'babel-eslint' ,
203
203
errors : [ { message : 'Missing JSX expression container around literal string' } ]
204
204
} , {
205
- code : [
206
- ' class Comp1 extends Component {' ,
207
- ' render() {' ,
208
- ' const varObjectTest = { testKey : (<div>test</div>) };' ,
209
- ' return varObjectTest.testKey;' ,
210
- ' }' ,
211
- '}'
212
- ] . join ( '\n' ) ,
205
+ code : `
206
+ class Comp1 extends Component {
207
+ render() {
208
+ const varObjectTest = { testKey : (<div>test</div>) };
209
+ return varObjectTest.testKey;
210
+ }
211
+ }
212
+ ` ,
213
213
parser : 'babel-eslint' ,
214
214
errors : [ { message : 'Missing JSX expression container around literal string' } ]
215
215
} , {
216
- code : [
217
- ' var Hello = createReactClass({' ,
218
- ' foo: (<div>hello</div>),' ,
219
- ' render() {' ,
220
- ' return this.foo;' ,
221
- ' },' ,
222
- ' });'
223
- ] . join ( '\n' ) ,
216
+ code : `
217
+ var Hello = createReactClass({
218
+ foo: (<div>hello</div>),
219
+ render() {
220
+ return this.foo;
221
+ },
222
+ });
223
+ ` ,
224
224
parser : 'babel-eslint' ,
225
225
errors : [ { message : 'Missing JSX expression container around literal string' } ]
226
226
} , {
227
- code : [
228
- ' class Comp1 extends Component {' ,
229
- ' render() {' ,
230
- ' return (' ,
231
- ' <div>' ,
232
- ' asdjfl' ,
233
- ' </div>' ,
234
- ' );' ,
235
- ' }' ,
236
- '}'
237
- ] . join ( '\n' ) ,
227
+ code : `
228
+ class Comp1 extends Component {
229
+ render() {
230
+ return (
231
+ <div>
232
+ asdjfl
233
+ </div>
234
+ );
235
+ }
236
+ }
237
+ ` ,
238
238
parser : 'babel-eslint' ,
239
239
errors : [ { message : 'Missing JSX expression container around literal string' } ]
240
240
} , {
241
- code : [
242
- ' class Comp1 extends Component {' ,
243
- ' render() {' ,
244
- ' return (' ,
245
- ' <div>' ,
246
- ' asdjfl' ,
247
- ' test' ,
248
- ' foo' ,
249
- ' </div>' ,
250
- ' );' ,
251
- ' }' ,
252
- '}'
253
- ] . join ( '\n' ) ,
241
+ code : `
242
+ class Comp1 extends Component {
243
+ render() {
244
+ return (
245
+ <div>
246
+ asdjfl
247
+ test
248
+ foo
249
+ </div>
250
+ );
251
+ }
252
+ }
253
+ ` ,
254
254
parser : 'babel-eslint' ,
255
255
errors : [ { message : 'Missing JSX expression container around literal string' } ]
256
256
} , {
257
- code : [
258
- ' class Comp1 extends Component {' ,
259
- ' render() {' ,
260
- ' return (' ,
261
- ' <div>' ,
262
- ' {\ 'asdjfl\'}' ,
263
- ' test' ,
264
- ' {\ 'foo\'}' ,
265
- ' </div>' ,
266
- ' );' ,
267
- ' }' ,
268
- '}'
269
- ] . join ( '\n' ) ,
257
+ code : `
258
+ class Comp1 extends Component {
259
+ render() {
260
+ return (
261
+ <div>
262
+ {'asdjfl'}
263
+ test
264
+ {'foo'}
265
+ </div>
266
+ );
267
+ }
268
+ }
269
+ ` ,
270
270
parser : 'babel-eslint' ,
271
271
errors : [ { message : 'Missing JSX expression container around literal string' } ]
272
272
} , {
@@ -304,11 +304,11 @@ ruleTester.run('jsx-no-literals', rule, {
304
304
options : [ { noStrings : true } ] ,
305
305
errors : [ { message : 'Strings not allowed in JSX files' } ]
306
306
} , {
307
- code : [
308
- ' <Foo>' ,
309
- ' {`Test`}' ,
310
- ' </Foo>'
311
- ] . join ( '\n' ) ,
307
+ code : `
308
+ <Foo>
309
+ {\ `Test\`}
310
+ </Foo>
311
+ ` ,
312
312
options : [ { noStrings : true } ] ,
313
313
errors : [ { message : 'Strings not allowed in JSX files' } ]
314
314
} , {
0 commit comments