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

no-extra-parens handles some MemberExpressions incorrectly #9156

Closed
not-an-aardvark opened this issue Aug 25, 2017 · 5 comments
Closed

no-extra-parens handles some MemberExpressions incorrectly #9156

not-an-aardvark opened this issue Aug 25, 2017 · 5 comments
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

Comments

@not-an-aardvark
Copy link
Member

not-an-aardvark commented Aug 25, 2017

Tell us about your environment

  • ESLint Version: master
  • Node Version: 8.4.0
  • npm Version: 5.3.0

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

default

Please show your full configuration:

Configuration
rules:
  no-extra-parens: error

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

(foo()).bar;

new (foo.bar().Baz);

What did you expect to happen?

I expected an error to be reported on line 1, and no error on line 3.

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

An error was reported on line 3, but no error was reported on line 1.

edit: added a false positive case

@not-an-aardvark not-an-aardvark 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 labels Aug 25, 2017
@not-an-aardvark not-an-aardvark changed the title no-extra-parens has a false negative with MemberExpressions no-extra-parens handles some MemberExpressions incorrectly Aug 26, 2017
@jackyho112
Copy link
Contributor

jackyho112 commented Sep 4, 2017

May I give this a go? Will start working on this right away.

@not-an-aardvark
Copy link
Member Author

Sure, feel free. Thanks for contributing!

@jackyho112
Copy link
Contributor

jackyho112 commented Sep 4, 2017

@not-an-aardvark

I have been familiarizing myself with the library and investigating the issue. I think I have a few ideas on how to fix them. I do want to confirm the logics with you though.

The first line should have a warning because parens around a call expression are unnecessary?

The third line should not have a warning because parens are necessary around a member expression within a new expression?

@platinumazure
Copy link
Member

I think extra parens around a new expression should only be allowed if there are intervening parentheses.

new (Foo.Bar.Baz);  // unnecessary parens
new (Foo.Bar().Baz);  // necessary parens

@jackyho112
Copy link
Contributor

jackyho112 commented Sep 6, 2017

I will look into it more to find the necessary or unnecessary aspects of these parens.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 15, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 15, 2018
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

No branches or pull requests

3 participants