Skip to content

Commit

Permalink
[Fix] jsx-curly-brace-presence: Fix error related to tags line break
Browse files Browse the repository at this point in the history
Fixes #1727.
  • Loading branch information
rafbgarcia authored and ljharb committed Dec 12, 2019
1 parent 4fedc5f commit 0f8d790
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -298,7 +298,11 @@ module.exports = {
return areRuleConditionsSatisfied(parent, config, OPTION_NEVER);
}

function shouldCheckForMissingCurly(parent, config) {
function shouldCheckForMissingCurly(node, config) {
if (node.raw.trim() === '') {
return false;
}
const parent = node.parent;
if (
parent.children &&
parent.children.length === 1 &&
Expand All @@ -322,7 +326,7 @@ module.exports = {
},

'Literal, JSXText': (node) => {
if (shouldCheckForMissingCurly(node.parent, userConfig)) {
if (shouldCheckForMissingCurly(node, userConfig)) {
reportMissingCurly(node);
}
}
Expand Down
15 changes: 15 additions & 0 deletions tests/lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -376,6 +376,21 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
<MyComponent p={<Foo>Bar</Foo>}>
</MyComponent>
`
},
{
code: `
<MyComponent>
<div>
<p>
<span>
{"foo"}
</span>
</p>
</div>
</MyComponent>
`,
parser: parsers.BABEL_ESLINT,
options: [{children: 'always'}]
}
],

Expand Down

0 comments on commit 0f8d790

Please sign in to comment.