@@ -138,6 +138,36 @@ ruleTester.run('jsx-no-literals', rule, {
138
138
code : '<Foo bar={100} />' ,
139
139
parser : 'babel-eslint' ,
140
140
options : [ { noStrings : true } ]
141
+ } , {
142
+ code : '<Foo bar={null} />' ,
143
+ parser : 'babel-eslint' ,
144
+ options : [ { noStrings : true } ]
145
+ } , {
146
+ code : '<Foo bar={{}} />' ,
147
+ parser : 'babel-eslint' ,
148
+ options : [ { noStrings : true } ]
149
+ } , {
150
+ code : [
151
+ 'class Comp1 extends Component {' ,
152
+ ' asdf() {}' ,
153
+ ' render() {' ,
154
+ ' return <Foo bar={this.asdf} />;' ,
155
+ ' }' ,
156
+ '}'
157
+ ] . join ( '\n' ) ,
158
+ parser : 'babel-eslint' ,
159
+ options : [ { noStrings : true } ]
160
+ } , {
161
+ code : [
162
+ 'class Comp1 extends Component {' ,
163
+ ' render() {' ,
164
+ ' let foo = `bar`;' ,
165
+ ' return <div />;' ,
166
+ ' }' ,
167
+ '}'
168
+ ] . join ( '\n' ) ,
169
+ parser : 'babel-eslint' ,
170
+ options : [ { noStrings : true } ]
141
171
} , {
142
172
code : `
143
173
<Foo bar="test">
@@ -161,6 +191,32 @@ ruleTester.run('jsx-no-literals', rule, {
161
191
} , {
162
192
code : '<Foo bar={100} />' ,
163
193
options : [ { noStrings : true } ]
194
+ } , {
195
+ code : '<Foo bar={null} />' ,
196
+ options : [ { noStrings : true } ]
197
+ } , {
198
+ code : '<Foo bar={{}} />' ,
199
+ options : [ { noStrings : true } ]
200
+ } , {
201
+ code : [
202
+ 'class Comp1 extends Component {' ,
203
+ ' asdf() {}' ,
204
+ ' render() {' ,
205
+ ' return <Foo bar={this.asdf} />;' ,
206
+ ' }' ,
207
+ '}'
208
+ ] . join ( '\n' ) ,
209
+ options : [ { noStrings : true } ]
210
+ } , {
211
+ code : [
212
+ 'class Comp1 extends Component {' ,
213
+ ' render() {' ,
214
+ ' let foo = `bar`;' ,
215
+ ' return <div />;' ,
216
+ ' }' ,
217
+ '}'
218
+ ] . join ( '\n' ) ,
219
+ options : [ { noStrings : true } ]
164
220
}
165
221
166
222
] ,
@@ -289,6 +345,32 @@ ruleTester.run('jsx-no-literals', rule, {
289
345
` ,
290
346
options : [ { noStrings : true } ] ,
291
347
errors : [ { message : 'Strings not allowed in JSX files' } ]
348
+ } , {
349
+ code : [
350
+ '<Foo>' ,
351
+ ' {`Test`}' ,
352
+ '</Foo>'
353
+ ] . join ( '\n' ) ,
354
+ parser : 'babel-eslint' ,
355
+ options : [ { noStrings : true } ] ,
356
+ errors : [ { message : 'Strings not allowed in JSX files' } ]
357
+ } , {
358
+ code : [
359
+ '<Foo>' ,
360
+ ' {`Test`}' ,
361
+ '</Foo>'
362
+ ] . join ( '\n' ) ,
363
+ options : [ { noStrings : true } ] ,
364
+ errors : [ { message : 'Strings not allowed in JSX files' } ]
365
+ } , {
366
+ code : '<Foo bar={`Test`} />' ,
367
+ parser : 'babel-eslint' ,
368
+ options : [ { noStrings : true } ] ,
369
+ errors : [ { message : 'Strings not allowed in JSX files' } ]
370
+ } , {
371
+ code : '<Foo bar={`Test`} />' ,
372
+ options : [ { noStrings : true } ] ,
373
+ errors : [ { message : 'Strings not allowed in JSX files' } ]
292
374
}
293
375
]
294
376
} ) ;
0 commit comments