Skip to content

Commit 454a292

Browse files
authored
feat!: update eslint:recommended configuration (#20210)
* feat!: update `eslint:recommended` configuration * revert docs changes * revert eslint-config-eslint changes * fix formatting * add v10 migration note for `eslint:recommended` updates
1 parent 4f880ee commit 454a292

6 files changed

Lines changed: 28 additions & 3 deletions

File tree

docs/src/use/migrate-to-10.0.0.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The lists below are ordered roughly by the number of users each change is expect
1818
- [Node.js < v20.19, v21, v23 are no longer supported](#drop-old-node)
1919
- [New configuration file lookup algorithm](#config-lookup-from-file)
2020
- [`no-shadow-restricted-names` now reports `globalThis` by default](#no-shadow-restricted-names)
21+
- [`eslint:recommended` has been updated](#eslint-recommended)
2122

2223
### Breaking changes for plugin developers
2324

@@ -74,3 +75,15 @@ In ESLint v10, the [`no-shadow-restricted-names`](../rules/no-shadow-restricted-
7475
```
7576

7677
**Related issue(s):** [#19673](https://github.com/eslint/eslint/issues/19673)
78+
79+
## <a name="eslint-recommended"></a> `eslint:recommended` has been updated
80+
81+
Three new rules have been enabled in `eslint:recommended`:
82+
83+
- [`no-unassigned-vars`](../rules/no-unassigned-vars)
84+
- [`no-useless-assignment`](../rules/no-useless-assignment)
85+
- [`preserve-caught-error`](../rules/preserve-caught-error)
86+
87+
**To address:** Fix errors or disable these rules.
88+
89+
**Related issue(s):** [#19966](https://github.com/eslint/eslint/issues/19966)

lib/rules/no-unassigned-vars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
docs: {
1919
description:
2020
"Disallow `let` or `var` variables that are read but never assigned",
21-
recommended: false,
21+
recommended: true,
2222
url: "https://eslint.org/docs/latest/rules/no-unassigned-vars",
2323
},
2424

lib/rules/no-useless-assignment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ module.exports = {
130130
docs: {
131131
description:
132132
"Disallow variable assignments when the value is not used",
133-
recommended: false,
133+
recommended: true,
134134
url: "https://eslint.org/docs/latest/rules/no-useless-assignment",
135135
},
136136

lib/rules/preserve-caught-error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ module.exports = {
158158
docs: {
159159
description:
160160
"Disallow losing originally caught error when re-throwing custom errors",
161-
recommended: false,
161+
recommended: true,
162162
url: "https://eslint.org/docs/latest/rules/preserve-caught-error", // URL to the documentation page for this rule
163163
},
164164
/*

lib/types/rules.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3914,6 +3914,9 @@ export interface ESLintRules extends Linter.RulesRecord {
39143914
/**
39153915
* Rule to disallow `let` or `var` variables that are read but never assigned.
39163916
*
3917+
* @remarks
3918+
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
3919+
*
39173920
* @since 9.27.0
39183921
* @see https://eslint.org/docs/latest/rules/no-unassigned-vars
39193922
*/
@@ -4279,6 +4282,9 @@ export interface ESLintRules extends Linter.RulesRecord {
42794282
/**
42804283
* Rule to disallow variable assignments when the value is not used.
42814284
*
4285+
* @remarks
4286+
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
4287+
*
42824288
* @since 9.0.0-alpha.1
42834289
* @see https://eslint.org/docs/latest/rules/no-useless-assignment
42844290
*/
@@ -4944,6 +4950,9 @@ export interface ESLintRules extends Linter.RulesRecord {
49444950
/**
49454951
* Rule to disallow losing originally caught error when re-throwing custom errors.
49464952
*
4953+
* @remarks
4954+
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
4955+
*
49474956
* @since 9.35.0
49484957
* @see https://eslint.org/docs/latest/rules/preserve-caught-error
49494958
*/

packages/js/src/configs/eslint-recommended.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ module.exports = Object.freeze({
5959
"no-shadow-restricted-names": "error",
6060
"no-sparse-arrays": "error",
6161
"no-this-before-super": "error",
62+
"no-unassigned-vars": "error",
6263
"no-undef": "error",
6364
"no-unexpected-multiline": "error",
6465
"no-unreachable": "error",
@@ -68,10 +69,12 @@ module.exports = Object.freeze({
6869
"no-unused-labels": "error",
6970
"no-unused-private-class-members": "error",
7071
"no-unused-vars": "error",
72+
"no-useless-assignment": "error",
7173
"no-useless-backreference": "error",
7274
"no-useless-catch": "error",
7375
"no-useless-escape": "error",
7476
"no-with": "error",
77+
"preserve-caught-error": "error",
7578
"require-yield": "error",
7679
"use-isnan": "error",
7780
"valid-typeof": "error"

0 commit comments

Comments
 (0)