@@ -155,6 +155,22 @@ ruleTester.run('jsx-one-expression-per-line', rule, {
155155 code : '<App>{"foo"}</App>' ,
156156 options : [ { allow : 'single-child' } ] ,
157157 } ,
158+ {
159+ code : '<App>123</App>' ,
160+ options : [ { allow : 'non-jsx' } ] ,
161+ } ,
162+ {
163+ code : '<App>foo</App>' ,
164+ options : [ { allow : 'non-jsx' } ] ,
165+ } ,
166+ {
167+ code : '<App>{"foo"}</App>' ,
168+ options : [ { allow : 'non-jsx' } ] ,
169+ } ,
170+ {
171+ code : '<App>{<Bar />}</App>' ,
172+ options : [ { allow : 'non-jsx' } ] ,
173+ } ,
158174 {
159175 code : '<App>{foo && <Bar />}</App>' ,
160176 options : [ { allow : 'single-child' } ] ,
@@ -184,6 +200,38 @@ ruleTester.run('jsx-one-expression-per-line', rule, {
184200 ` ,
185201 features : [ 'fragment' , 'no-ts-old' ] , // TODO: FIXME: remove no-ts-old and fix
186202 } ,
203+ {
204+ code : '<App>Hello {name}</App>' ,
205+ options : [ { allow : 'non-jsx' } ] ,
206+ } ,
207+ {
208+ code : `
209+ <App>
210+ Hello {name} there!
211+ </App>` ,
212+ options : [ { allow : 'non-jsx' } ] ,
213+ } ,
214+ {
215+ code : `
216+ <App>
217+ Hello {<Bar />} there!
218+ </App>` ,
219+ options : [ { allow : 'non-jsx' } ] ,
220+ } ,
221+ {
222+ code : `
223+ <App>
224+ Hello {(<Bar />)} there!
225+ </App>` ,
226+ options : [ { allow : 'non-jsx' } ] ,
227+ } ,
228+ {
229+ code : `
230+ <App>
231+ Hello {(() => <Bar />)()} there!
232+ </App>` ,
233+ options : [ { allow : 'non-jsx' } ] ,
234+ } ,
187235 ] ) ,
188236
189237 invalid : parsers . all ( [
493541 ] ,
494542 parserOptions,
495543 } ,
544+ {
545+ code : `
546+ <Text style={styles.foo}>
547+ <Bar /> <Baz />
548+ </Text>
549+ ` ,
550+ output : `
551+ <Text style={styles.foo}>
552+ <Bar />${ ' ' /* intentional trailing space */ }
553+ {' '}
554+ <Baz />
555+ </Text>
556+ ` ,
557+ errors : [
558+ {
559+ messageId : 'moveToNewLine' ,
560+ data : { descriptor : 'Baz' } ,
561+ } ,
562+ ] ,
563+ options : [ { allow : 'non-jsx' } ] ,
564+ parserOptions,
565+ } ,
496566 {
497567 code : `
498568 <Text style={styles.foo}>
@@ -1257,6 +1327,23 @@ foo
12571327 } ,
12581328 ] ,
12591329 } ,
1330+ {
1331+ code : `
1332+ <App><Foo /></App>
1333+ ` ,
1334+ output : `
1335+ <App>
1336+ <Foo />
1337+ </App>
1338+ ` ,
1339+ options : [ { allow : 'non-jsx' } ] ,
1340+ errors : [
1341+ {
1342+ messageId : 'moveToNewLine' ,
1343+ data : { descriptor : 'Foo' } ,
1344+ } ,
1345+ ] ,
1346+ } ,
12601347 {
12611348 code : `
12621349 <App
0 commit comments