ESLint Plugin: Relax prefer-const for destructuring assignment#20737
Merged
Conversation
|
Size Change: 0 B Total Size: 864 kB ℹ️ View Unchanged
|
nerrad
approved these changes
Mar 9, 2020
Contributor
nerrad
left a comment
There was a problem hiding this comment.
I add my approval as a 👍 but I realize others might have comments as well so this is just a signal.
|
👍 from me as well! |
Member
|
I’m fine with the change proposed 👍 |
Member
Author
|
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. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from: #20693
This pull request seeks to update the default ESLint configuration of
prefer-constto allow aletassignment 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 ofletandconst) 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.