From 165365aa9224c6eb3998284da82291b7c446b79a Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 12 Mar 2020 09:24:07 -0400 Subject: [PATCH] ESLint Plugin: Relax `prefer-const` for destructuring assignment (#20737) --- packages/eslint-plugin/CHANGELOG.md | 4 ++++ packages/eslint-plugin/configs/esnext.js | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index a38e783e1adb9f..48149ffc4c43fb 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -1,5 +1,9 @@ ## Master +### New Features + +- The `prefer-const` rule included in the `recommended` and `esnext` rulesets has been relaxed to allow a `let` assignment if any of a [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) are reassigned. + ## 4.0.0 (2020-02-10) ### Breaking Changes diff --git a/packages/eslint-plugin/configs/esnext.js b/packages/eslint-plugin/configs/esnext.js index 35a758449571fc..4cdd60b0fa05ba 100644 --- a/packages/eslint-plugin/configs/esnext.js +++ b/packages/eslint-plugin/configs/esnext.js @@ -22,7 +22,12 @@ module.exports = { 'no-useless-constructor': 'error', 'no-var': 'error', 'object-shorthand': 'error', - 'prefer-const': 'error', + 'prefer-const': [ + 'error', + { + destructuring: 'all', + }, + ], quotes: [ 'error', 'single',