-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
ESLint Plugin: Relax prefer-const
for destructuring assignment
#20737
ESLint Plugin: Relax prefer-const
for destructuring assignment
#20737
Conversation
Size Change: 0 B Total Size: 864 kB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add my approval as a 👍 but I realize others might have comments as well so this is just a signal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, no objections from me 👍🏼
👍 from me as well! |
I’m fine with the change proposed 👍 |
I haven't witnessed any objections in or following the meeting discussion this week, so will assume this is a fine adjustment to merge. Thanks y'all. 👍 |
Extracted from: #20693
This pull request seeks to update the default ESLint configuration of
prefer-const
to allow alet
assignment if any of a destructuring assignment are reassigned. The intention with this change is to avoid scenarios where the developer must resort to cumbersome workarounds (like multiple destructuring assignments oflet
andconst
) when there is mixed reassignment of destructured variables. The potential downside of this change is that we lose "signalling" of intent to reassign when working with destructuring.Before:
After:
See rule configuration for more detail:
https://eslint.org/docs/rules/prefer-const#destructuring
I marked this as a "New Feature" instead of "Breaking Change". While technically the behavior is now different, it should not result in the introduction of any errors.
For a real-world example, see #20693 (specifically this assignment).
Testing Instructions:
Try incorporating a code snippet like those above somewhere in code, and observe the expected result.