@@ -42,6 +42,38 @@ ruleTester.run('jsx-curly-spacing', rule, {
4242 ] . join ( '\n' )
4343 } , {
4444 code : '<App foo={{ bar: true, baz: true }} />;'
45+ } , {
46+ code : '<App foo={bar} />;' ,
47+ options : [ { attributes : true } ]
48+ } , {
49+ code : [
50+ '<App foo={' ,
51+ 'bar' ,
52+ '} />;'
53+ ] . join ( '\n' ) ,
54+ options : [ { attributes : true } ]
55+ } , {
56+ code : '<App foo={{ bar: true, baz: true }} />;' ,
57+ options : [ { attributes : true } ]
58+ } , {
59+ code : '<App foo={bar} />;' ,
60+ options : [ { attributes : false } ]
61+ } , {
62+ code : [
63+ '<App foo={' ,
64+ 'bar' ,
65+ '} />;'
66+ ] . join ( '\n' ) ,
67+ options : [ { attributes : false } ]
68+ } , {
69+ code : '<App foo={{ bar: true, baz: true }} />;' ,
70+ options : [ { attributes : false } ]
71+ } , {
72+ code : '<App foo={ bar } />;' ,
73+ options : [ { attributes : false } ]
74+ } , {
75+ code : '<App foo={ { bar: true, baz: true } } />;' ,
76+ options : [ { attributes : false } ]
4577 } , {
4678 code : '<App foo={bar} />;' ,
4779 options : [ { when : 'never' } ]
@@ -281,6 +313,24 @@ ruleTester.run('jsx-curly-spacing', rule, {
281313 } , {
282314 message : 'There should be no space before \'}\''
283315 } ]
316+ } , {
317+ code : '<App foo={ bar } />;' ,
318+ output : '<App foo={bar} />;' ,
319+ options : [ { attributes : true } ] ,
320+ errors : [ {
321+ message : 'There should be no space after \'{\''
322+ } , {
323+ message : 'There should be no space before \'}\''
324+ } ]
325+ } , {
326+ code : '<App foo={ { bar: true, baz: true } } />;' ,
327+ output : '<App foo={{ bar: true, baz: true }} />;' ,
328+ options : [ { attributes : true } ] ,
329+ errors : [ {
330+ message : 'There should be no space after \'{\''
331+ } , {
332+ message : 'There should be no space before \'}\''
333+ } ]
284334 } , {
285335 code : '<App foo={ bar } />;' ,
286336 output : '<App foo={bar} />;' ,
@@ -413,6 +463,86 @@ ruleTester.run('jsx-curly-spacing', rule, {
413463 } , {
414464 message : 'A space is required before \'}\''
415465 } ]
466+ } , {
467+ code : '<App foo={ bar } />;' ,
468+ output : '<App foo={bar} />;' ,
469+ options : [ { attributes : true , when : 'never' } ] ,
470+ errors : [ {
471+ message : 'There should be no space after \'{\''
472+ } , {
473+ message : 'There should be no space before \'}\''
474+ } ]
475+ } , {
476+ code : [
477+ '<App foo={' ,
478+ 'bar' ,
479+ '} />;'
480+ ] . join ( '\n' ) ,
481+ output : '<App foo={bar} />;' ,
482+ options : [ { attributes : true , when : 'never' , allowMultiline : false } ] ,
483+ errors : [ {
484+ message : 'There should be no newline after \'{\''
485+ } , {
486+ message : 'There should be no newline before \'}\''
487+ } ]
488+ } , {
489+ code : '<App foo={ { bar: true, baz: true } } />;' ,
490+ output : '<App foo={{ bar: true, baz: true }} />;' ,
491+ options : [ { attributes : true , when : 'never' , spacing : { objectLiterals : 'never' } } ] ,
492+ errors : [ {
493+ message : 'There should be no space after \'{\''
494+ } , {
495+ message : 'There should be no space before \'}\''
496+ } ]
497+ } , {
498+ code : '<App foo={{ bar: true, baz: true }} />;' ,
499+ output : '<App foo={ { bar: true, baz: true } } />;' ,
500+ options : [ { attributes : true , when : 'never' , spacing : { objectLiterals : 'always' } } ] ,
501+ errors : [ {
502+ message : 'A space is required after \'{\''
503+ } , {
504+ message : 'A space is required before \'}\''
505+ } ]
506+ } , {
507+ code : '<App foo={bar} />;' ,
508+ output : '<App foo={ bar } />;' ,
509+ options : [ { attributes : true , when : 'always' } ] ,
510+ errors : [ {
511+ message : 'A space is required after \'{\''
512+ } , {
513+ message : 'A space is required before \'}\''
514+ } ]
515+ } , {
516+ code : [
517+ '<App foo={' ,
518+ 'bar' ,
519+ '} />;'
520+ ] . join ( '\n' ) ,
521+ output : '<App foo={ bar } />;' ,
522+ options : [ { attributes : true , when : 'always' , allowMultiline : false } ] ,
523+ errors : [ {
524+ message : 'There should be no newline after \'{\''
525+ } , {
526+ message : 'There should be no newline before \'}\''
527+ } ]
528+ } , {
529+ code : '<App foo={ { bar: true, baz: true } } />;' ,
530+ output : '<App foo={{ bar: true, baz: true }} />;' ,
531+ options : [ { attributes : true , when : 'always' , spacing : { objectLiterals : 'never' } } ] ,
532+ errors : [ {
533+ message : 'There should be no space after \'{\''
534+ } , {
535+ message : 'There should be no space before \'}\''
536+ } ]
537+ } , {
538+ code : '<App foo={{ bar: true, baz: true }} />;' ,
539+ output : '<App foo={ { bar: true, baz: true } } />;' ,
540+ options : [ { attributes : true , when : 'always' , spacing : { objectLiterals : 'always' } } ] ,
541+ errors : [ {
542+ message : 'A space is required after \'{\''
543+ } , {
544+ message : 'A space is required before \'}\''
545+ } ]
416546 } , {
417547 code : '<App foo={ bar } />;' ,
418548 output : '<App foo={bar} />;' ,
0 commit comments