Skip to content

Commit

Permalink
Fixed code style, added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
burtek committed Jan 11, 2024
1 parent 128e0bf commit 592484c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rules/jsx-one-expression-per-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ module.exports = {
return;
}

if (options.allow === 'non-jsx'
&& !children.find((child) => (child.type === 'JSXFragment' || child.type === 'JSXElement'))) {
if (
options.allow === 'non-jsx'
&& !children.find((child) => (child.type === 'JSXFragment' || child.type === 'JSXElement'))
) {
return;
}

Expand Down
21 changes: 21 additions & 0 deletions tests/lib/rules/jsx-one-expression-per-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,27 @@ ruleTester.run('jsx-one-expression-per-line', rule, {
</App>`,
options: [{ allow: 'non-jsx' }],
},
{
code: `
<App>
Hello {<Bar />} there!
</App>`,
options: [{ allow: 'non-jsx' }],
},
{
code: `
<App>
Hello {(<Bar />)} there!
</App>`,
options: [{ allow: 'non-jsx' }],
},
{
code: `
<App>
Hello {(() => <Bar />)()} there!
</App>`,
options: [{ allow: 'non-jsx' }],
},
]),

invalid: parsers.all([
Expand Down

0 comments on commit 592484c

Please sign in to comment.