@@ -233,6 +233,11 @@ ruleTester.run('jsx-indent', rule, {
233
233
' <Foo />' ,
234
234
'</App>'
235
235
] . join ( '\n' ) ,
236
+ output : [
237
+ '<App>' ,
238
+ '\t<Foo />' ,
239
+ '</App>'
240
+ ] . join ( '\n' ) ,
236
241
options : [ 'tab' ] ,
237
242
parserOptions : parserOptions ,
238
243
errors : [ { message : 'Expected indentation of 1 tab character but found 0.' } ]
@@ -282,6 +287,19 @@ ruleTester.run('jsx-indent', rule, {
282
287
' );' ,
283
288
'}'
284
289
] . join ( '\n' ) ,
290
+ // The detection logic only thinks <App> is indented wrong, not the other
291
+ // two lines following. I *think* because it incorrectly uses <App>'s indention
292
+ // as the baseline for the next two, instead of the realizing the entire three
293
+ // lines are wrong together. See #608
294
+ /* output: [
295
+ 'function App() {',
296
+ ' return (',
297
+ ' <App>',
298
+ ' <Foo />',
299
+ ' </App>',
300
+ ' );',
301
+ '}'
302
+ ].join('\n'), */
285
303
options : [ 2 ] ,
286
304
parserOptions : parserOptions ,
287
305
errors : [ { message : 'Expected indentation of 4 space characters but found 0.' } ]
@@ -291,6 +309,11 @@ ruleTester.run('jsx-indent', rule, {
291
309
' {test}' ,
292
310
'</App>'
293
311
] . join ( '\n' ) ,
312
+ output : [
313
+ '<App>' ,
314
+ ' {test}' ,
315
+ '</App>'
316
+ ] . join ( '\n' ) ,
294
317
parserOptions : parserOptions ,
295
318
errors : [
296
319
{ message : 'Expected indentation of 4 space characters but found 3.' }
@@ -305,6 +328,15 @@ ruleTester.run('jsx-indent', rule, {
305
328
' ))}' ,
306
329
'</App>'
307
330
] . join ( '\n' ) ,
331
+ output : [
332
+ '<App>' ,
333
+ ' {options.map((option, index) => (' ,
334
+ ' <option key={index} value={option.key}>' ,
335
+ ' {option.name}' ,
336
+ ' </option>' ,
337
+ ' ))}' ,
338
+ '</App>'
339
+ ] . join ( '\n' ) ,
308
340
parserOptions : parserOptions ,
309
341
errors : [
310
342
{ message : 'Expected indentation of 12 space characters but found 11.' }
@@ -315,6 +347,11 @@ ruleTester.run('jsx-indent', rule, {
315
347
'{test}' ,
316
348
'</App>'
317
349
] . join ( '\n' ) ,
350
+ output : [
351
+ '<App>' ,
352
+ '\t{test}' ,
353
+ '</App>'
354
+ ] . join ( '\n' ) ,
318
355
parserOptions : parserOptions ,
319
356
options : [ 'tab' ] ,
320
357
errors : [
@@ -330,6 +367,15 @@ ruleTester.run('jsx-indent', rule, {
330
367
'\t))}' ,
331
368
'</App>'
332
369
] . join ( '\n' ) ,
370
+ output : [
371
+ '<App>' ,
372
+ '\t{options.map((option, index) => (' ,
373
+ '\t\t<option key={index} value={option.key}>' ,
374
+ '\t\t\t{option.name}' ,
375
+ '\t\t</option>' ,
376
+ '\t))}' ,
377
+ '</App>'
378
+ ] . join ( '\n' ) ,
333
379
parserOptions : parserOptions ,
334
380
options : [ 'tab' ] ,
335
381
errors : [
@@ -369,10 +415,7 @@ ruleTester.run('jsx-indent', rule, {
369
415
errors : [
370
416
{ message : 'Expected indentation of 2 space characters but found 4.' }
371
417
]
372
- }
373
- // Tests for future work. See the comment on line 42-43 in the rule near to fixable: 'whitespace' meta property,
374
- // Right now fixer function doesn't support replacing tabs with whitespaces and vice-versa.
375
- /* , {
418
+ } , {
376
419
code : [
377
420
'<App>\n' ,
378
421
' <Foo />\n' ,
@@ -404,5 +447,5 @@ ruleTester.run('jsx-indent', rule, {
404
447
errors : [
405
448
{ message : 'Expected indentation of 2 space characters but found 0.' }
406
449
]
407
- }*/ ]
450
+ } ]
408
451
} ) ;
0 commit comments