Skip to content

Commit 2a595fd

Browse files
dustinyosteljharb
authored andcommitted
[Fix] jsx-curly-brace-presence: Fix filter of undefined error with whitespace inside jsx attr curlies
1 parent 0c1cb28 commit 2a595fd

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,18 @@ module.exports = {
242242
}
243243

244244
function hasAdjacentJsxExpressionContainers(node, children) {
245+
if (!children) {
246+
return false;
247+
}
245248
const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child));
246249
const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral);
247250

248251
return adjSiblings.some(x => x.type && x.type === 'JSXExpressionContainer');
249252
}
250253
function hasAdjacentJsx(node, children) {
254+
if (!children) {
255+
return false;
256+
}
251257
const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child));
252258
const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral);
253259

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

+3
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
145145
{
146146
code: `<App prop='bar'>{'foo \\n bar'}</App>`
147147
},
148+
{
149+
code: `<App prop={ ' ' }/>`
150+
},
148151
{
149152
code: `<MyComponent prop='bar'>foo</MyComponent>`,
150153
options: [{props: 'never'}]

0 commit comments

Comments
 (0)