@@ -31,23 +31,35 @@ function closingSlashOptions(option) {
3131 return [ {
3232 closingSlash : option ,
3333 beforeSelfClosing : 'allow' ,
34- afterOpening : 'allow'
34+ afterOpening : 'allow' ,
35+ beforeClosing : 'allow'
3536 } ] ;
3637}
3738
3839function beforeSelfClosingOptions ( option ) {
3940 return [ {
4041 closingSlash : 'allow' ,
4142 beforeSelfClosing : option ,
42- afterOpening : 'allow'
43+ afterOpening : 'allow' ,
44+ beforeClosing : 'allow'
4345 } ] ;
4446}
4547
4648function afterOpeningOptions ( option ) {
4749 return [ {
4850 closingSlash : 'allow' ,
4951 beforeSelfClosing : 'allow' ,
50- afterOpening : option
52+ afterOpening : option ,
53+ beforeClosing : 'allow'
54+ } ] ;
55+ }
56+
57+ function beforeClosingOptions ( option ) {
58+ return [ {
59+ closingSlash : 'allow' ,
60+ beforeSelfClosing : 'allow' ,
61+ afterOpening : 'allow' ,
62+ beforeClosing : option
5163 } ] ;
5264}
5365
@@ -139,19 +151,46 @@ ruleTester.run('jsx-tag-spacing', rule, {
139151 'App/>'
140152 ] . join ( '\n' ) ,
141153 options : afterOpeningOptions ( 'allow-multiline' )
154+ } , {
155+ code : '<App />' ,
156+ options : beforeClosingOptions ( 'never' )
157+ } , {
158+ code : '<App></App>' ,
159+ options : beforeClosingOptions ( 'never' )
160+ } , {
161+ code : [
162+ '<App' ,
163+ 'foo="bar"' ,
164+ '>' ,
165+ '</App>'
166+ ] . join ( '\n' ) ,
167+ options : beforeClosingOptions ( 'never' )
168+ } , {
169+ code : '<App ></App >' ,
170+ options : beforeClosingOptions ( 'always' )
171+ } , {
172+ code : [
173+ '<App' ,
174+ 'foo="bar"' ,
175+ '>' ,
176+ '</App >'
177+ ] . join ( '\n' ) ,
178+ options : beforeClosingOptions ( 'always' )
142179 } , {
143180 code : '<App/>' ,
144181 options : [ {
145182 closingSlash : 'never' ,
146183 beforeSelfClosing : 'never' ,
147- afterOpening : 'never'
184+ afterOpening : 'never' ,
185+ beforeClosing : 'never'
148186 } ]
149187 } , {
150188 code : '< App / >' ,
151189 options : [ {
152190 closingSlash : 'always' ,
153191 beforeSelfClosing : 'always' ,
154- afterOpening : 'always'
192+ afterOpening : 'always' ,
193+ beforeClosing : 'always'
155194 } ]
156195 } ] ,
157196
@@ -306,5 +345,55 @@ ruleTester.run('jsx-tag-spacing', rule, {
306345 output : '<App/>' ,
307346 errors : [ { message : 'A space is forbidden after opening bracket' } ] ,
308347 options : afterOpeningOptions ( 'allow-multiline' )
348+ } , {
349+ code : '<App ></App>' ,
350+ output : '<App></App>' ,
351+ errors : [ { message : 'A space is forbidden before closing bracket' } ] ,
352+ options : beforeClosingOptions ( 'never' )
353+ } , {
354+ code : '<App></App >' ,
355+ output : '<App></App>' ,
356+ errors : [ { message : 'A space is forbidden before closing bracket' } ] ,
357+ options : beforeClosingOptions ( 'never' )
358+ } , {
359+ code : [
360+ '<App' ,
361+ 'foo="bar"' ,
362+ '>' ,
363+ '</App >'
364+ ] . join ( '\n' ) ,
365+ output : [
366+ '<App' ,
367+ 'foo="bar"' ,
368+ '>' ,
369+ '</App>'
370+ ] . join ( '\n' ) ,
371+ errors : [ { message : 'A space is forbidden before closing bracket' } ] ,
372+ options : beforeClosingOptions ( 'never' )
373+ } , {
374+ code : '<App></App >' ,
375+ output : '<App ></App >' ,
376+ errors : [ { message : 'Whitespace is required before closing bracket' } ] ,
377+ options : beforeClosingOptions ( 'always' )
378+ } , {
379+ code : '<App ></App>' ,
380+ output : '<App ></App >' ,
381+ errors : [ { message : 'Whitespace is required before closing bracket' } ] ,
382+ options : beforeClosingOptions ( 'always' )
383+ } , {
384+ code : [
385+ '<App' ,
386+ 'foo="bar"' ,
387+ '>' ,
388+ '</App>'
389+ ] . join ( '\n' ) ,
390+ output : [
391+ '<App' ,
392+ 'foo="bar"' ,
393+ '>' ,
394+ '</App >'
395+ ] . join ( '\n' ) ,
396+ errors : [ { message : 'Whitespace is required before closing bracket' } ] ,
397+ options : beforeClosingOptions ( 'always' )
309398 } ]
310399} ) ;
0 commit comments