Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix[jsx-curly-brace-presence] Fix error related to tag line breaks #2521

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
}
rafbgarcia marked this conversation as resolved.
Show resolved Hide resolved
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