@@ -31,23 +31,35 @@ function closingSlashOptions(option) {
31
31
return [ {
32
32
closingSlash : option ,
33
33
beforeSelfClosing : 'allow' ,
34
- afterOpening : 'allow'
34
+ afterOpening : 'allow' ,
35
+ beforeClosing : 'allow'
35
36
} ] ;
36
37
}
37
38
38
39
function beforeSelfClosingOptions ( option ) {
39
40
return [ {
40
41
closingSlash : 'allow' ,
41
42
beforeSelfClosing : option ,
42
- afterOpening : 'allow'
43
+ afterOpening : 'allow' ,
44
+ beforeClosing : 'allow'
43
45
} ] ;
44
46
}
45
47
46
48
function afterOpeningOptions ( option ) {
47
49
return [ {
48
50
closingSlash : 'allow' ,
49
51
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
51
63
} ] ;
52
64
}
53
65
@@ -139,19 +151,46 @@ ruleTester.run('jsx-tag-spacing', rule, {
139
151
'App/>'
140
152
] . join ( '\n' ) ,
141
153
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' )
142
179
} , {
143
180
code : '<App/>' ,
144
181
options : [ {
145
182
closingSlash : 'never' ,
146
183
beforeSelfClosing : 'never' ,
147
- afterOpening : 'never'
184
+ afterOpening : 'never' ,
185
+ beforeClosing : 'never'
148
186
} ]
149
187
} , {
150
188
code : '< App / >' ,
151
189
options : [ {
152
190
closingSlash : 'always' ,
153
191
beforeSelfClosing : 'always' ,
154
- afterOpening : 'always'
192
+ afterOpening : 'always' ,
193
+ beforeClosing : 'always'
155
194
} ]
156
195
} ] ,
157
196
@@ -306,5 +345,55 @@ ruleTester.run('jsx-tag-spacing', rule, {
306
345
output : '<App/>' ,
307
346
errors : [ { message : 'A space is forbidden after opening bracket' } ] ,
308
347
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' )
309
398
} ]
310
399
} ) ;
0 commit comments