Skip to content

Commit 0f8d790

Browse files
rafbgarcialjharb
authored andcommitted
[Fix] jsx-curly-brace-presence: Fix error related to tags line break
Fixes #1727.
1 parent 4fedc5f commit 0f8d790

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/rules/jsx-curly-brace-presence.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ module.exports = {
298298
return areRuleConditionsSatisfied(parent, config, OPTION_NEVER);
299299
}
300300

301-
function shouldCheckForMissingCurly(parent, config) {
301+
function shouldCheckForMissingCurly(node, config) {
302+
if (node.raw.trim() === '') {
303+
return false;
304+
}
305+
const parent = node.parent;
302306
if (
303307
parent.children &&
304308
parent.children.length === 1 &&
@@ -322,7 +326,7 @@ module.exports = {
322326
},
323327

324328
'Literal, JSXText': (node) => {
325-
if (shouldCheckForMissingCurly(node.parent, userConfig)) {
329+
if (shouldCheckForMissingCurly(node, userConfig)) {
326330
reportMissingCurly(node);
327331
}
328332
}

tests/lib/rules/jsx-curly-brace-presence.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,21 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
376376
<MyComponent p={<Foo>Bar</Foo>}>
377377
</MyComponent>
378378
`
379+
},
380+
{
381+
code: `
382+
<MyComponent>
383+
<div>
384+
<p>
385+
<span>
386+
{"foo"}
387+
</span>
388+
</p>
389+
</div>
390+
</MyComponent>
391+
`,
392+
parser: parsers.BABEL_ESLINT,
393+
options: [{children: 'always'}]
379394
}
380395
],
381396

0 commit comments

Comments
 (0)