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

vedadeepta commented Sep 12, 2019

  • Fixes #2201
  • Includes test

Overview of change:

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

…h children on next line
@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 vedadeepta:2201-jsx-curly-brace-presence-multiline branch from 1f1593b to 21d8470 Sep 12, 2019
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 vedadeepta:2201-jsx-curly-brace-presence-multiline branch from bf4bb8d to 489ced3 Sep 13, 2019
@ljharb ljharb merged commit 489ced3 into yannickcr:master Sep 13, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.01%) to 97.573%
Details
@ljharb
ljharb approved these changes Sep 13, 2019

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

This comment has been minimized.

Copy link
@taion

taion Oct 1, 2019

Contributor

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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.