Skip to content

Commit

Permalink
[Fix] jsx-curly-brace-presence: Fix filter of undefined error with …
Browse files Browse the repository at this point in the history
…whitespace inside jsx attr curlies
  • Loading branch information
dustinyoste authored and ljharb committed Oct 11, 2019
1 parent 0c1cb28 commit 2a595fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -242,12 +242,18 @@ module.exports = {
}

function hasAdjacentJsxExpressionContainers(node, children) {
if (!children) {
return false;
}
const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child));
const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral);

return adjSiblings.some(x => x.type && x.type === 'JSXExpressionContainer');
}
function hasAdjacentJsx(node, children) {
if (!children) {
return false;
}
const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child));
const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral);

Expand Down
3 changes: 3 additions & 0 deletions tests/lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -145,6 +145,9 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
{
code: `<App prop='bar'>{'foo \\n bar'}</App>`
},
{
code: `<App prop={ ' ' }/>`
},
{
code: `<MyComponent prop='bar'>foo</MyComponent>`,
options: [{props: 'never'}]
Expand Down

0 comments on commit 2a595fd

Please sign in to comment.