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

Update: Check computed property keys in no-extra-parens #11952

Merged
merged 2 commits into from Jul 17, 2019

Conversation

@mdjermanovic
Copy link
Member

commented Jul 5, 2019

What is the purpose of this pull request? (put an "X" next to item)

[X] Bug fix

Tell us about your environment

  • ESLint Version: 6.0.1
  • Node Version: 10.16.0
  • npm Version: 6.9.0

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
module.exports = {
  parserOptions: {
    ecmaVersion: 6,
  },
  rules: {
    "no-extra-parens": "error"
  }
};

What did you do? Please include the actual source code causing the issue.

const obj = {
  *[(Symbol.iterator)]() {}
}

const { [(a)]:b } = {}

What did you expect to happen?

2 errors.

What actually happened? Please include the actual, raw output from ESLint.

No errors.

What changes did you make? (Give an overview)

Added the Property handler to no-extra-parens, to check computed property keys.

This affects both ObjectExpression properties and ObjectPattern properties.

Is there anything you'd like reviewers to focus on?

  • I guess this is a bug fix that adds more reported warnings, rather than a new behavior.
  • The same check could be done within ObjectExpression and ObjectPattern handlers instead of the Property handler. I'm not sure which way would be better. ObjectExpression is already checking values.
  • const a = { [b, c]: 1 } is indeed a syntax error without parens around the sequence expression.
  • There will be a separate PR for classes.

@eslint eslint bot added the triage label Jul 5, 2019

@platinumazure
Copy link
Member

left a comment

LGTM, thanks!

I would be okay with merging this as is, but I'll ask this: Do you want to add a couple of test cases with a mix of unnecessary and necessary parentheses, and show that only the unnecessary parentheses are removed?

@platinumazure platinumazure added accepted bug rule and removed triage labels Jul 5, 2019

@platinumazure
Copy link
Member

left a comment

LGTM, thanks! Nice test coverage!

@g-plane

g-plane approved these changes Jul 5, 2019

Copy link
Member

left a comment

LGTM, thanks!

@mysticatea mysticatea merged commit b974fcb into eslint:master Jul 17, 2019

9 checks passed

commit-message PR title follows commit message guidelines
Details
continuous-integration Build #20190705.3 succeeded
Details
continuous-integration (Test on Node.js 10 (Linux)) Test on Node.js 10 (Linux) succeeded
Details
continuous-integration (Test on Node.js 12 (Linux)) Test on Node.js 12 (Linux) succeeded
Details
continuous-integration (Test on Node.js 12 (Windows)) Test on Node.js 12 (Windows) succeeded
Details
continuous-integration (Test on Node.js 12 (macOS)) Test on Node.js 12 (macOS) succeeded
Details
continuous-integration (Test on Node.js 8 (Linux)) Test on Node.js 8 (Linux) succeeded
Details
licence/cla Contributor License Agreement is signed.
Details
release-monitor No patch release is pending
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.