@@ -102,7 +102,10 @@ ruleTester.run('jsx-no-useless-fragment', rule, {
102102 {
103103 code : '<p>moo<>foo</></p>' ,
104104 output : '<p>moofoo</p>' ,
105- errors : [ { messageId : 'NeedsMoreChildren' } , { messageId : 'ChildOfHtmlElement' } ] ,
105+ errors : [
106+ { messageId : 'NeedsMoreChildren' , type : 'JSXFragment' } ,
107+ { messageId : 'ChildOfHtmlElement' , type : 'JSXFragment' } ,
108+ ] ,
106109 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
107110 } ,
108111 {
@@ -114,13 +117,16 @@ ruleTester.run('jsx-no-useless-fragment', rule, {
114117 {
115118 code : '<p><>{meow}</></p>' ,
116119 output : '<p>{meow}</p>' ,
117- errors : [ { messageId : 'NeedsMoreChildren' } , { messageId : 'ChildOfHtmlElement' } ] ,
120+ errors : [
121+ { messageId : 'NeedsMoreChildren' , type : 'JSXFragment' } ,
122+ { messageId : 'ChildOfHtmlElement' , type : 'JSXFragment' } ,
123+ ] ,
118124 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
119125 } ,
120126 {
121127 code : '<><div/></>' ,
122128 output : '<div/>' ,
123- errors : [ { messageId : 'NeedsMoreChildren' } ] ,
129+ errors : [ { messageId : 'NeedsMoreChildren' , type : 'JSXFragment' } ] ,
124130 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
125131 } ,
126132 {
@@ -132,12 +138,12 @@ ruleTester.run('jsx-no-useless-fragment', rule, {
132138 output : `
133139 <div/>
134140 ` ,
135- errors : [ { messageId : 'NeedsMoreChildren' } ] ,
141+ errors : [ { messageId : 'NeedsMoreChildren' , type : 'JSXFragment' } ] ,
136142 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
137143 } ,
138144 {
139145 code : '<Fragment />' ,
140- errors : [ { messageId : 'NeedsMoreChildren' } ] ,
146+ errors : [ { messageId : 'NeedsMoreChildren' , type : 'JSXElement' } ] ,
141147 } ,
142148 {
143149 code : `
@@ -148,7 +154,7 @@ ruleTester.run('jsx-no-useless-fragment', rule, {
148154 output : `
149155 <Foo />
150156 ` ,
151- errors : [ { messageId : 'NeedsMoreChildren' } ] ,
157+ errors : [ { messageId : 'NeedsMoreChildren' , type : 'JSXElement' } ] ,
152158 } ,
153159 {
154160 code : `
@@ -162,31 +168,34 @@ ruleTester.run('jsx-no-useless-fragment', rule, {
162168 fragment : 'SomeFragment' ,
163169 } ,
164170 } ,
165- errors : [ { messageId : 'NeedsMoreChildren' } ] ,
171+ errors : [ { messageId : 'NeedsMoreChildren' , type : 'JSXElement' } ] ,
166172 } ,
167173 {
168174 // Not safe to fix this case because `Eeee` might require child be ReactElement
169175 code : '<Eeee><>foo</></Eeee>' ,
170176 output : null ,
171- errors : [ { messageId : 'NeedsMoreChildren' } ] ,
177+ errors : [ { messageId : 'NeedsMoreChildren' , type : 'JSXFragment' } ] ,
172178 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
173179 } ,
174180 {
175181 code : '<div><>foo</></div>' ,
176182 output : '<div>foo</div>' ,
177- errors : [ { messageId : 'NeedsMoreChildren' } , { messageId : 'ChildOfHtmlElement' } ] ,
183+ errors : [
184+ { messageId : 'NeedsMoreChildren' , type : 'JSXFragment' } ,
185+ { messageId : 'ChildOfHtmlElement' , type : 'JSXFragment' } ,
186+ ] ,
178187 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
179188 } ,
180189 {
181190 code : '<div><>{"a"}{"b"}</></div>' ,
182191 output : '<div>{"a"}{"b"}</div>' ,
183- errors : [ { messageId : 'ChildOfHtmlElement' } ] ,
192+ errors : [ { messageId : 'ChildOfHtmlElement' , type : 'JSXFragment' } ] ,
184193 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old and next test case
185194 } ,
186195 {
187196 code : '<div><>{"a"}{"b"}</></div>' ,
188197 output : '<div><>{"a"}{"b"}</></div>' ,
189- errors : [ { messageId : 'ChildOfHtmlElement' } ] ,
198+ errors : [ { messageId : 'ChildOfHtmlElement' , type : 'JSXFragment' } ] ,
190199 features : [ 'fragment' , 'ts-old' , 'no-ts-new' , 'no-babel' , 'no-default' ] ,
191200 } ,
192201 {
@@ -202,13 +211,13 @@ ruleTester.run('jsx-no-useless-fragment', rule, {
202211 <Eeee />
203212 {"a"}{"b"}
204213 </section>` ,
205- errors : [ { messageId : 'ChildOfHtmlElement' } ] ,
214+ errors : [ { messageId : 'ChildOfHtmlElement' , type : 'JSXFragment' } ] ,
206215 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
207216 } ,
208217 {
209218 code : '<div><Fragment>{"a"}{"b"}</Fragment></div>' ,
210219 output : '<div>{"a"}{"b"}</div>' ,
211- errors : [ { messageId : 'ChildOfHtmlElement' } ] ,
220+ errors : [ { messageId : 'ChildOfHtmlElement' , type : 'JSXElement' } ] ,
212221 } ,
213222 {
214223 // whitepace tricky case
@@ -226,13 +235,16 @@ ruleTester.run('jsx-no-useless-fragment', rule, {
226235
227236 git <b>hub</b>
228237 </section>` ,
229- errors : [ { messageId : 'ChildOfHtmlElement' } , { messageId : 'ChildOfHtmlElement' } ] ,
238+ errors : [
239+ { messageId : 'ChildOfHtmlElement' , type : 'JSXFragment' , line : 3 } ,
240+ { messageId : 'ChildOfHtmlElement' , type : 'JSXFragment' , line : 7 } ,
241+ ] ,
230242 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
231243 } ,
232244 {
233245 code : '<div>a <>{""}{""}</> a</div>' ,
234246 output : '<div>a {""}{""} a</div>' ,
235- errors : [ { messageId : 'ChildOfHtmlElement' } ] ,
247+ errors : [ { messageId : 'ChildOfHtmlElement' , type : 'JSXFragment' } ] ,
236248 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
237249 } ,
238250 {
@@ -250,13 +262,16 @@ ruleTester.run('jsx-no-useless-fragment', rule, {
250262 </html>
251263 );
252264 ` ,
253- errors : [ { messageId : 'NeedsMoreChildren' } , { messageId : 'ChildOfHtmlElement' } ] ,
265+ errors : [
266+ { messageId : 'NeedsMoreChildren' , type : 'JSXElement' , line : 4 } ,
267+ { messageId : 'ChildOfHtmlElement' , type : 'JSXElement' , line : 4 } ,
268+ ] ,
254269 } ,
255270 // Ensure allowExpressions still catches expected violations
256271 {
257272 code : '<><Foo>{moo}</Foo></>' ,
258273 options : [ { allowExpressions : true } ] ,
259- errors : [ { messageId : 'NeedsMoreChildren' } ] ,
274+ errors : [ { messageId : 'NeedsMoreChildren' , type : 'JSXFragment' } ] ,
260275 output : '<Foo>{moo}</Foo>' ,
261276 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old
262277 } ,
0 commit comments