Skip to content

Commit

Permalink
[refactor]jsx-curly-brace-presence: function hasAdjacentJsxExpressi…
Browse files Browse the repository at this point in the history
…onContainers & tests
  • Loading branch information
vedadeepta committed Sep 13, 2019
1 parent 465ea48 commit 4377ed1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 1 addition & 7 deletions lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -229,13 +229,7 @@ module.exports = {
const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child));
const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral);

for (let i = 0; i < adjSiblings.length; i++) {
const currentChild = adjSiblings[i];
if (currentChild.type && currentChild.type === 'JSXExpressionContainer') {
return true;
}
}
return false;
return adjSiblings.some(x => x.type && x.type === 'JSXExpressionContainer');
}

function shouldCheckForUnnecessaryCurly(parent, node, config) {
Expand Down
8 changes: 6 additions & 2 deletions tests/lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -390,7 +390,11 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
`,
parser: parsers.BABEL_ESLINT,
options: [{children: 'never'}],
errors: 3
errors: [
{message: unnecessaryCurlyMessage},
{message: unnecessaryCurlyMessage},
{message: unnecessaryCurlyMessage}
]
},
{
code: `
Expand All @@ -415,7 +419,7 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
`,
parser: parsers.BABEL_ESLINT,
options: [{children: 'never'}],
errors: 2
errors: [{message: unnecessaryCurlyMessage}, {message: unnecessaryCurlyMessage}]
},
{
code: `<MyComponent prop='bar'>foo</MyComponent>`,
Expand Down

0 comments on commit 4377ed1

Please sign in to comment.