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

Disallow parens around single-line JSX expressions #778

Closed
feross opened this issue Feb 8, 2017 · 3 comments

Comments

@feross
Copy link
Member

commented Feb 8, 2017

This rule restricts the use of parentheses to only where they are necessary.

Currently, this rule is set to:

    "no-extra-parens": ["error", "functions"]

I would like to investigate enabling a few more of the restrictions. Specifically, requiring the following seems desirable:

const Component = (<div><p /></div>) // avoid

// ok
const Component = (
  <div>
    <p />
  </div>
)

http://eslint.org/docs/rules/no-extra-parens

@feross feross added the enhancement label Feb 8, 2017

@feross feross modified the milestones: standard v9, standard v10 Feb 8, 2017

@feross feross changed the title Make no-extra-parens rule stricter Disallow parens around single-line JSX expressions Mar 1, 2017

@feross

This comment has been minimized.

Copy link
Member Author

commented Mar 1, 2017

I attempted to set this rule to:

    "no-extra-parens": ["error", "all", {
      "conditionalAssign": false,
      "returnAssign": false,
      "nestedBinaryExpressions": false,
      "ignoreJSX": "multi-line"
    }],

but I ran into some issues.

We really just want to add the JSX enforcement and no other new restrictions. Unfortunately, to get the JSX enforcement, we need to change the first parameter from "function" to "all". This also enables checking for extra parens around all kind of expressions, like:

obj.set(x, y, (z ? 25 : undefined))

And this is just too restrictive, IMO. I'll open an issue on ESLint about adding additional options so we can just enforce no extra parens around functions and single-line JSX statements.

@feross

This comment has been minimized.

Copy link
Member Author

commented Mar 2, 2017

ESLint issue: eslint/eslint#8174

@feross feross modified the milestones: standard v11, standard v10 Mar 2, 2017

@feross feross added the blocked label Mar 2, 2017

@feross feross modified the milestones: standard v12, standard v13 Aug 28, 2018

@feross feross modified the milestones: standard v13, standard v14 Jul 5, 2019

@feross

This comment has been minimized.

Copy link
Member Author

commented Aug 14, 2019

The issue didn't reach consensus with the ESLint team (back in Jan 2018) so we can't fix this.

If someone feels strongly about this, I'd love it if you could please open a new issue with the ESLint team and reference the original one I opened (eslint/eslint#8174). It is possible that the new attempt will reach consensus with the team. If you open a new issue, lmk and I will re-open this issue.

@feross feross closed this Aug 14, 2019

@feross feross removed this from the standard 14 milestone Aug 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.