Relax rule: Only enforce const
in destructuring when all variables are constant
#1325
Labels
const
in destructuring when all variables are constant
#1325
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:This is because
b
is never mutated. So it wants us to rewrite the code like this:When 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 beconst
. So, I'll enable the{"destructing": "all"}
option. https://eslint.org/docs/rules/prefer-const#destructuringFeedback welcome.
The text was updated successfully, but these errors were encountered: