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

[camelcase] false negative in destructuring with assignment #13025

Closed
yeonjuan opened this issue Mar 10, 2020 · 2 comments · Fixed by #13027
Closed

[camelcase] false negative in destructuring with assignment #13025

yeonjuan opened this issue Mar 10, 2020 · 2 comments · Fixed by #13027
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

@yeonjuan
Copy link
Member

yeonjuan commented Mar 10, 2020

Tell us about your environment

  • ESLint Version: 7.0.0-alpha.2
  • Node Version: v11.15.0
  • npm Version: 6.7.0

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

default

Please show your full configuration:

Configuration

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

/*eslint camelcase: ["error"] */
var obj = {};

obj.fo_o = d;  // Warning
({ a: obj.fo_o } = {d: d}); // No Warning
([ob.fo_o] = bar); // No Warning

What did you expect to happen?

I expect 3 warnings.

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

One warning

The below cases are not warned

({ a: obj.fo_o } = {d: d}); // No warning
([ob.fo_o] = bar); // No Warning

Are you willing to submit a pull request to fix this bug?

Yes!

I think the proper behavior should be as belows.

/*eslint camelcase: ["error"] */
obj.fo_o = d; // warning
({ a: obj.fo_o } = bar); // warning
([ob.fo_o] = bar); // warning
/*eslint camelcase: ["error", {"ignoreDestructuring": true}] */
obj.fo_o = d; // warning
({ a: obj.fo_o } = bar); // warning
([ob.fo_o] = bar); // warning
/*eslint camelcase: ["error", {"properties": "never"}] */
obj.fo_o = d; // No warning
({ a: obj.fo_o } = {d: d}); // No warning
([ob.fo_o] = bar); // No warning
@yeonjuan yeonjuan added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Mar 10, 2020
@mdjermanovic
Copy link
Member

This looks like a bug to me, too.

Regarding ignoreDestructuring, I think it's only for shorthand variable initialization/assignments and in my opinion these should be errors:

/*eslint camelcase: ["error", {"ignoreDestructuring": true}] */

({ a: obj.fo_o } = bar); // error
([ob.fo_o] = bar); // error

@yeonjuan
Copy link
Member Author

@mdjermanovic

Regarding ignoreDestructuring, I think it's only for shorthand variable initialization/assignments and in my opinion these should be errors:

Okay, I agreed. I changed the examples in the issue. Thanks.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Mar 20, 2020
kaicataldo pushed a commit that referenced this issue Mar 26, 2020
…3027)

* Fix: check assignment property target in camelcase (fixes #13025)

* check camelcase

* remove useless check

* fix is isAssignmentTargetPropertyInDestructuring
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 24, 2020
@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 Sep 24, 2020
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 a pull request may close this issue.

3 participants