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]jsx-curly-brace-presence: report unnecessary curly braces on multline child expressions #2409

Merged

Conversation

vedadeepta
Copy link
Contributor

Overview of change:

Checks for more than one non-whitespace literal children of JsxElement instead of directly checking for chidlren.length !== 1.

@vedadeepta vedadeepta changed the title [fix]sort-comp: report unnecessary curly braces on multline child expressions [fix]jsx-curly-brace-presence: report unnecessary curly braces on multline child expressions Sep 12, 2019
@vedadeepta vedadeepta force-pushed the 2201-jsx-curly-brace-presence-multiline branch from 1f1593b to 21d8470 Compare September 12, 2019 14:20
tests/lib/rules/jsx-curly-brace-presence.js Show resolved Hide resolved
lib/rules/jsx-curly-brace-presence.js Outdated Show resolved Hide resolved
lib/rules/jsx-curly-brace-presence.js Outdated Show resolved Hide resolved
lib/rules/jsx-curly-brace-presence.js Show resolved Hide resolved
tests/lib/rules/jsx-curly-brace-presence.js Outdated Show resolved Hide resolved
tests/lib/rules/jsx-curly-brace-presence.js Outdated Show resolved Hide resolved
lib/rules/jsx-curly-brace-presence.js Outdated Show resolved Hide resolved
…o-danger-with-children`: add `isWhiteSpaces` to `lib/util/jsx`
@ljharb ljharb force-pushed the 2201-jsx-curly-brace-presence-multiline branch from bf4bb8d to 489ced3 Compare September 13, 2019 17:51
@ljharb ljharb merged commit 489ced3 into jsx-eslint:master Sep 13, 2019

function hasAdjacentJsxExpressionContainers(node, children) {
const childrenExcludingWhitespaceLiteral = children.filter(child => !isWhiteSpaceLiteral(child));
const adjSiblings = getAdjacentSiblings(node, childrenExcludingWhitespaceLiteral);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check is quite right. We now get stuff like:

           <div>
-            Confirm{' '}
+            Confirm
             <button type="button" onClick={this.onClickYes}>

But this is not the same markup and it's not desirable here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

react/jsx-curly-brace-presence {"children": "never"} doesn't error on multiline expressions
3 participants