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

Fix: prefer-const when using destructuring assign (fixes #8308) #10924

Merged
merged 8 commits into from Oct 19, 2018

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Oct 5, 2018

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

[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Changed prefer-const so that it considers destructuring assignment with an object property to disqualify using const for variables used in the same destructuring assignment.

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

Is this the correct approach? It seems like the key to fixing this bug was to consider object properties in destructuring assignment to be the key factor in determining if a variable should be declared with const. I'm not 100% this is the correct assumption, so please double-check that.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Oct 5, 2018
@nzakas nzakas requested a review from mysticatea October 5, 2018 17:52
@nzakas nzakas added 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 Oct 5, 2018
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 so far, but was unsure about a few possible typos/unintentional changes.

tests/lib/rules/prefer-const.js Outdated Show resolved Hide resolved
tests/lib/rules/prefer-const.js Show resolved Hide resolved
tests/lib/rules/prefer-const.js Outdated Show resolved Hide resolved
@nzakas
Copy link
Member Author

nzakas commented Oct 17, 2018

@mysticatea if you have time, can you take a look at this pull request?

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

Thanks! I noticed one potential bug, but this generally looks like a good approach.

lib/rules/prefer-const.js Show resolved Hide resolved
@nzakas
Copy link
Member Author

nzakas commented Oct 17, 2018 via email

Copy link
Member

@not-an-aardvark not-an-aardvark 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!

Copy link
Member

@kaicataldo kaicataldo 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 for working on this!

@kaicataldo kaicataldo merged commit 57ef0fd into master Oct 19, 2018
@nzakas nzakas deleted the issue8308 branch October 19, 2018 16:30
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 18, 2019
@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 Apr 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.

None yet

5 participants