-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
When we added prefer-const, we kept the default setting which is quite strict when there's a bunch of variables being assigned at once in destructuring. For example, this is considered an error:
let { a, b } = obj
a = a + 1This is because b is never mutated. So it wants us to rewrite the code like this:
let { a } = obj
const { b } = obj
a = a + 1When there are many variables being assigned at once through destructuring, or when variables are being switched from mutated vs. not mutated, this causes a lot of churn. I'd rather err on the side of leniency here and just allow the whole block to be let if any of the variables are mutated.
Only when we can affirmatively say that all variables are const, should the whole thing be forced to be const. So, I'll enable the {"destructing": "all"} option. https://eslint.org/docs/rules/prefer-const#destructuring
Feedback welcome.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status