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
Merged

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

merged 2 commits into from
Jul 17, 2019

Conversation

mdjermanovic
Copy link
Member

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-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jul 5, 2019
Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

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 There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jul 5, 2019
Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Nice test coverage!

Copy link
Member

@g-plane g-plane left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants