eslint 9.15.0 → 9.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/lib/linter/source-code-fixer.js +1 -1
  3. package/lib/rules/accessor-pairs.js +5 -4
  4. package/lib/rules/default-case-last.js +2 -2
  5. package/lib/rules/for-direction.js +2 -2
  6. package/lib/rules/getter-return.js +3 -1
  7. package/lib/rules/id-length.js +2 -1
  8. package/lib/rules/id-match.js +6 -1
  9. package/lib/rules/new-cap.js +1 -1
  10. package/lib/rules/no-bitwise.js +4 -1
  11. package/lib/rules/no-compare-neg-zero.js +1 -1
  12. package/lib/rules/no-duplicate-imports.js +3 -1
  13. package/lib/rules/no-empty-pattern.js +3 -1
  14. package/lib/rules/no-eval.js +3 -1
  15. package/lib/rules/no-implicit-globals.js +3 -1
  16. package/lib/rules/no-inner-declarations.js +2 -2
  17. package/lib/rules/no-multi-assign.js +3 -1
  18. package/lib/rules/no-param-reassign.js +2 -2
  19. package/lib/rules/no-plusplus.js +3 -1
  20. package/lib/rules/no-promise-executor-return.js +3 -1
  21. package/lib/rules/no-script-url.js +3 -3
  22. package/lib/rules/no-shadow.js +4 -2
  23. package/lib/rules/no-undef.js +3 -1
  24. package/lib/rules/no-underscore-dangle.js +1 -0
  25. package/lib/rules/no-unsafe-negation.js +3 -1
  26. package/lib/rules/no-unsafe-optional-chaining.js +3 -1
  27. package/lib/rules/no-unused-vars.js +613 -2
  28. package/lib/rules/no-use-before-define.js +2 -1
  29. package/lib/rules/no-useless-assignment.js +9 -0
  30. package/lib/rules/no-useless-computed-key.js +1 -1
  31. package/lib/rules/no-useless-rename.js +5 -1
  32. package/lib/rules/no-void.js +3 -1
  33. package/lib/rules/prefer-const.js +6 -4
  34. package/lib/rules/prefer-object-spread.js +2 -2
  35. package/lib/rules/prefer-promise-reject-errors.js +3 -1
  36. package/lib/rules/prefer-regex-literals.js +3 -1
  37. package/lib/rules/require-atomic-updates.js +3 -1
  38. package/lib/rules/require-unicode-regexp.js +2 -2
  39. package/lib/rules/sort-keys.js +10 -1
  40. package/lib/rules/sort-vars.js +4 -3
  41. package/lib/rules/use-isnan.js +1 -2
  42. package/lib/rules/valid-typeof.js +4 -3
  43. package/lib/shared/flags.js +1 -1
  44. package/lib/types/rules/stylistic-issues.d.ts +4 -0
  45. package/package.json +6 -6
package/README.md CHANGED
@@ -300,7 +300,7 @@ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
300
300
  <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
301
301
  <p><a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
302
302
  <p><a href="https://www.serptriumph.com/"><img src="https://images.opencollective.com/serp-triumph5/fea3074/logo.png" alt="SERP Triumph" height="64"></a> <a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3>
303
- <p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340?v=4" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a></p>
303
+ <p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340?v=4" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465?v=4" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a></p>
304
304
  <h3>Technology Sponsors</h3>
305
305
  Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
306
306
  <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
@@ -107,7 +107,7 @@ SourceCodeFixer.applyFixes = function(sourceText, messages, shouldFix) {
107
107
  }
108
108
 
109
109
  messages.forEach(problem => {
110
- if (Object.hasOwn(problem, "fix")) {
110
+ if (Object.hasOwn(problem, "fix") && problem.fix) {
111
111
  fixes.push(problem);
112
112
  } else {
113
113
  remainingMessages.push(problem);
@@ -177,10 +177,11 @@ module.exports = {
177
177
  }
178
178
  },
179
179
  create(context) {
180
- const [config] = context.options;
181
- const checkGetWithoutSet = config.getWithoutSet === true;
182
- const checkSetWithoutGet = config.setWithoutGet !== false;
183
- const enforceForClassMembers = config.enforceForClassMembers !== false;
180
+ const [{
181
+ getWithoutSet: checkGetWithoutSet,
182
+ setWithoutGet: checkSetWithoutGet,
183
+ enforceForClassMembers
184
+ }] = context.options;
184
185
  const sourceCode = context.sourceCode;
185
186
 
186
187
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @fileoverview Rule to enforce default clauses in switch statements to be last
2
+ * @fileoverview Rule to enforce `default` clauses in switch statements to be last
3
3
  * @author Milos Djermanovic
4
4
  */
5
5
 
@@ -15,7 +15,7 @@ module.exports = {
15
15
  type: "suggestion",
16
16
 
17
17
  docs: {
18
- description: "Enforce default clauses in switch statements to be last",
18
+ description: "Enforce `default` clauses in switch statements to be last",
19
19
  recommended: false,
20
20
  url: "https://eslint.org/docs/latest/rules/default-case-last"
21
21
  },
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @fileoverview enforce "for" loop update clause moving the counter in the right direction.(for-direction)
2
+ * @fileoverview enforce `for` loop update clause moving the counter in the right direction.(for-direction)
3
3
  * @author Aladdin-ADD<hh_2013@foxmail.com>
4
4
  */
5
5
 
@@ -21,7 +21,7 @@ module.exports = {
21
21
  type: "problem",
22
22
 
23
23
  docs: {
24
- description: "Enforce \"for\" loop update clause moving the counter in the right direction",
24
+ description: "Enforce `for` loop update clause moving the counter in the right direction",
25
25
  recommended: true,
26
26
  url: "https://eslint.org/docs/latest/rules/for-direction"
27
27
  },
@@ -42,7 +42,9 @@ module.exports = {
42
42
  meta: {
43
43
  type: "problem",
44
44
 
45
- defaultOptions: [{}],
45
+ defaultOptions: [{
46
+ allowImplicit: false
47
+ }],
46
48
 
47
49
  docs: {
48
50
  description: "Enforce `return` statements in getters",
@@ -25,7 +25,8 @@ module.exports = {
25
25
  defaultOptions: [{
26
26
  exceptionPatterns: [],
27
27
  exceptions: [],
28
- min: 2
28
+ min: 2,
29
+ properties: "always"
29
30
  }],
30
31
 
31
32
  docs: {
@@ -20,7 +20,12 @@ module.exports = {
20
20
  meta: {
21
21
  type: "suggestion",
22
22
 
23
- defaultOptions: ["^.+$", {}],
23
+ defaultOptions: ["^.+$", {
24
+ classFields: false,
25
+ ignoreDestructuring: false,
26
+ onlyDeclarations: false,
27
+ properties: false
28
+ }],
24
29
 
25
30
  docs: {
26
31
  description: "Require identifiers to match a specified regular expression",
@@ -118,7 +118,7 @@ module.exports = {
118
118
 
119
119
  create(context) {
120
120
  const [config] = context.options;
121
- const skipProperties = config.properties === false;
121
+ const skipProperties = !config.properties;
122
122
 
123
123
  const newIsCapExceptions = config.newIsCapExceptions.reduce(invert, {});
124
124
  const newIsCapExceptionPattern = config.newIsCapExceptionPattern ? new RegExp(config.newIsCapExceptionPattern, "u") : null;
@@ -25,7 +25,10 @@ module.exports = {
25
25
  meta: {
26
26
  type: "suggestion",
27
27
 
28
- defaultOptions: [{ allow: [] }],
28
+ defaultOptions: [{
29
+ allow: [],
30
+ int32Hint: false
31
+ }],
29
32
 
30
33
  docs: {
31
34
  description: "Disallow bitwise operators",
@@ -14,7 +14,7 @@ module.exports = {
14
14
  type: "problem",
15
15
 
16
16
  docs: {
17
- description: "Disallow comparing against -0",
17
+ description: "Disallow comparing against `-0`",
18
18
  recommended: true,
19
19
  url: "https://eslint.org/docs/latest/rules/no-compare-neg-zero"
20
20
  },
@@ -232,7 +232,9 @@ module.exports = {
232
232
  meta: {
233
233
  type: "problem",
234
234
 
235
- defaultOptions: [{}],
235
+ defaultOptions: [{
236
+ includeExports: false
237
+ }],
236
238
 
237
239
  docs: {
238
240
  description: "Disallow duplicate module imports",
@@ -15,7 +15,9 @@ module.exports = {
15
15
  meta: {
16
16
  type: "problem",
17
17
 
18
- defaultOptions: [{}],
18
+ defaultOptions: [{
19
+ allowObjectPatternsAsParameters: false
20
+ }],
19
21
 
20
22
  docs: {
21
23
  description: "Disallow empty destructuring patterns",
@@ -42,7 +42,9 @@ module.exports = {
42
42
  meta: {
43
43
  type: "suggestion",
44
44
 
45
- defaultOptions: [{}],
45
+ defaultOptions: [{
46
+ allowIndirect: false
47
+ }],
46
48
 
47
49
  docs: {
48
50
  description: "Disallow the use of `eval()`",
@@ -14,7 +14,9 @@ module.exports = {
14
14
  meta: {
15
15
  type: "suggestion",
16
16
 
17
- defaultOptions: [{}],
17
+ defaultOptions: [{
18
+ lexicalBindings: false
19
+ }],
18
20
 
19
21
  docs: {
20
22
  description: "Disallow declarations in the global scope",
@@ -47,7 +47,7 @@ module.exports = {
47
47
  meta: {
48
48
  type: "problem",
49
49
 
50
- defaultOptions: ["functions"],
50
+ defaultOptions: ["functions", { blockScopedFunctions: "allow" }],
51
51
 
52
52
  docs: {
53
53
  description: "Disallow variable or `function` declarations in nested blocks",
@@ -77,10 +77,10 @@ module.exports = {
77
77
 
78
78
  create(context) {
79
79
  const both = context.options[0] === "both";
80
+ const { blockScopedFunctions } = context.options[1];
80
81
 
81
82
  const sourceCode = context.sourceCode;
82
83
  const ecmaVersion = context.languageOptions.ecmaVersion;
83
- const blockScopedFunctions = context.options[1]?.blockScopedFunctions ?? "allow";
84
84
 
85
85
  /**
86
86
  * Ensure that a given node is at a program or function body's root.
@@ -15,7 +15,9 @@ module.exports = {
15
15
  meta: {
16
16
  type: "suggestion",
17
17
 
18
- defaultOptions: [{}],
18
+ defaultOptions: [{
19
+ ignoreNonDeclaration: false
20
+ }],
19
21
 
20
22
  docs: {
21
23
  description: "Disallow use of chained assignment expressions",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @fileoverview Disallow reassignment of function parameters.
2
+ * @fileoverview Disallow reassigning function parameters.
3
3
  * @author Nat Burns
4
4
  */
5
5
  "use strict";
@@ -16,7 +16,7 @@ module.exports = {
16
16
  type: "suggestion",
17
17
 
18
18
  docs: {
19
- description: "Disallow reassigning `function` parameters",
19
+ description: "Disallow reassigning function parameters",
20
20
  recommended: false,
21
21
  url: "https://eslint.org/docs/latest/rules/no-param-reassign"
22
22
  },
@@ -50,7 +50,9 @@ module.exports = {
50
50
  meta: {
51
51
  type: "suggestion",
52
52
 
53
- defaultOptions: [{}],
53
+ defaultOptions: [{
54
+ allowForLoopAfterthoughts: false
55
+ }],
54
56
 
55
57
  docs: {
56
58
  description: "Disallow the unary operators `++` and `--`",
@@ -141,7 +141,9 @@ module.exports = {
141
141
  meta: {
142
142
  type: "problem",
143
143
 
144
- defaultOptions: [{}],
144
+ defaultOptions: [{
145
+ allowVoid: false
146
+ }],
145
147
 
146
148
  docs: {
147
149
  description: "Disallow returning values from Promise executor functions",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @fileoverview Rule to flag when using javascript: urls
2
+ * @fileoverview Rule to disallow `javascript:` URLs
3
3
  * @author Ilya Volodin
4
4
  */
5
5
  /* eslint no-script-url: 0 -- Code is checking to report such URLs */
@@ -18,7 +18,7 @@ module.exports = {
18
18
  type: "suggestion",
19
19
 
20
20
  docs: {
21
- description: "Disallow `javascript:` urls",
21
+ description: "Disallow `javascript:` URLs",
22
22
  recommended: false,
23
23
  url: "https://eslint.org/docs/latest/rules/no-script-url"
24
24
  },
@@ -33,7 +33,7 @@ module.exports = {
33
33
  create(context) {
34
34
 
35
35
  /**
36
- * Check whether a node's static value starts with "javascript:" or not.
36
+ * Check whether a node's static value starts with `javascript:` or not.
37
37
  * And report an error for unexpected script URL.
38
38
  * @param {ASTNode} node node to check
39
39
  * @returns {void}
@@ -31,7 +31,9 @@ module.exports = {
31
31
 
32
32
  defaultOptions: [{
33
33
  allow: [],
34
- hoist: "functions"
34
+ builtinGlobals: false,
35
+ hoist: "functions",
36
+ ignoreOnInitialization: false
35
37
  }],
36
38
 
37
39
  docs: {
@@ -45,7 +47,7 @@ module.exports = {
45
47
  type: "object",
46
48
  properties: {
47
49
  builtinGlobals: { type: "boolean" },
48
- hoist: { enum: ["all", "functions", "never"], default: "functions" },
50
+ hoist: { enum: ["all", "functions", "never"] },
49
51
  allow: {
50
52
  type: "array",
51
53
  items: {
@@ -28,7 +28,9 @@ module.exports = {
28
28
  meta: {
29
29
  type: "problem",
30
30
 
31
- defaultOptions: [{}],
31
+ defaultOptions: [{
32
+ typeof: false
33
+ }],
32
34
 
33
35
  docs: {
34
36
  description: "Disallow the use of undeclared variables unless mentioned in `/*global */` comments",
@@ -22,6 +22,7 @@ module.exports = {
22
22
  allowFunctionParams: true,
23
23
  allowInArrayDestructuring: true,
24
24
  allowInObjectDestructuring: true,
25
+ enforceInClassFields: false,
25
26
  enforceInMethodNames: false
26
27
  }],
27
28
 
@@ -51,7 +51,9 @@ module.exports = {
51
51
  meta: {
52
52
  type: "problem",
53
53
 
54
- defaultOptions: [{}],
54
+ defaultOptions: [{
55
+ enforceForOrderingRelations: false
56
+ }],
55
57
 
56
58
  docs: {
57
59
  description: "Disallow negating the left operand of relational operators",
@@ -23,7 +23,9 @@ module.exports = {
23
23
  meta: {
24
24
  type: "problem",
25
25
 
26
- defaultOptions: [{}],
26
+ defaultOptions: [{
27
+ disallowArithmeticOperators: false
28
+ }],
27
29
 
28
30
  docs: {
29
31
  description: "Disallow use of optional chaining in contexts where the `undefined` value is not allowed",