@@ -233,6 +233,11 @@ ruleTester.run('jsx-indent', rule, {
233233 ' <Foo />' ,
234234 '</App>'
235235 ] . join ( '\n' ) ,
236+ output : [
237+ '<App>' ,
238+ '\t<Foo />' ,
239+ '</App>'
240+ ] . join ( '\n' ) ,
236241 options : [ 'tab' ] ,
237242 parserOptions : parserOptions ,
238243 errors : [ { message : 'Expected indentation of 1 tab character but found 0.' } ]
@@ -282,6 +287,19 @@ ruleTester.run('jsx-indent', rule, {
282287 ' );' ,
283288 '}'
284289 ] . 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'), */
285303 options : [ 2 ] ,
286304 parserOptions : parserOptions ,
287305 errors : [ { message : 'Expected indentation of 4 space characters but found 0.' } ]
@@ -291,6 +309,11 @@ ruleTester.run('jsx-indent', rule, {
291309 ' {test}' ,
292310 '</App>'
293311 ] . join ( '\n' ) ,
312+ output : [
313+ '<App>' ,
314+ ' {test}' ,
315+ '</App>'
316+ ] . join ( '\n' ) ,
294317 parserOptions : parserOptions ,
295318 errors : [
296319 { message : 'Expected indentation of 4 space characters but found 3.' }
@@ -305,6 +328,15 @@ ruleTester.run('jsx-indent', rule, {
305328 ' ))}' ,
306329 '</App>'
307330 ] . 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' ) ,
308340 parserOptions : parserOptions ,
309341 errors : [
310342 { message : 'Expected indentation of 12 space characters but found 11.' }
@@ -315,6 +347,11 @@ ruleTester.run('jsx-indent', rule, {
315347 '{test}' ,
316348 '</App>'
317349 ] . join ( '\n' ) ,
350+ output : [
351+ '<App>' ,
352+ '\t{test}' ,
353+ '</App>'
354+ ] . join ( '\n' ) ,
318355 parserOptions : parserOptions ,
319356 options : [ 'tab' ] ,
320357 errors : [
@@ -330,6 +367,15 @@ ruleTester.run('jsx-indent', rule, {
330367 '\t))}' ,
331368 '</App>'
332369 ] . 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' ) ,
333379 parserOptions : parserOptions ,
334380 options : [ 'tab' ] ,
335381 errors : [
@@ -369,10 +415,7 @@ ruleTester.run('jsx-indent', rule, {
369415 errors : [
370416 { message : 'Expected indentation of 2 space characters but found 4.' }
371417 ]
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+ } , {
376419 code : [
377420 '<App>\n' ,
378421 ' <Foo />\n' ,
@@ -404,5 +447,5 @@ ruleTester.run('jsx-indent', rule, {
404447 errors : [
405448 { message : 'Expected indentation of 2 space characters but found 0.' }
406449 ]
407- }*/ ]
450+ } ]
408451} ) ;
0 commit comments