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 filter of undefined #2460

Merged
merged 1 commit into from Oct 15, 2019
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
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