eslint 10.3.0 → 10.4.1

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 (49) hide show
  1. package/README.md +3 -3
  2. package/bin/eslint.js +28 -12
  3. package/lib/config-api.js +7 -1
  4. package/lib/eslint/eslint.js +29 -6
  5. package/lib/linter/code-path-analysis/code-path-analyzer.js +2 -2
  6. package/lib/linter/code-path-analysis/code-path-state.js +10 -6
  7. package/lib/linter/code-path-analysis/debug-helpers.js +12 -1
  8. package/lib/rules/capitalized-comments.js +3 -1
  9. package/lib/rules/class-methods-use-this.js +1 -2
  10. package/lib/rules/default-param-last.js +1 -2
  11. package/lib/rules/eqeqeq.js +3 -1
  12. package/lib/rules/for-direction.js +55 -11
  13. package/lib/rules/func-name-matching.js +2 -0
  14. package/lib/rules/func-style.js +1 -2
  15. package/lib/rules/init-declarations.js +7 -8
  16. package/lib/rules/logical-assignment-operators.js +4 -1
  17. package/lib/rules/max-classes-per-file.js +4 -2
  18. package/lib/rules/max-depth.js +3 -0
  19. package/lib/rules/max-lines-per-function.js +3 -0
  20. package/lib/rules/max-lines.js +3 -0
  21. package/lib/rules/max-nested-callbacks.js +3 -0
  22. package/lib/rules/max-params.js +4 -2
  23. package/lib/rules/max-statements.js +3 -0
  24. package/lib/rules/no-array-constructor.js +1 -2
  25. package/lib/rules/no-dupe-class-members.js +1 -2
  26. package/lib/rules/no-duplicate-imports.js +1 -2
  27. package/lib/rules/no-empty-function.js +1 -2
  28. package/lib/rules/no-invalid-this.js +1 -2
  29. package/lib/rules/no-loop-func.js +1 -2
  30. package/lib/rules/no-loss-of-precision.js +1 -2
  31. package/lib/rules/no-magic-numbers.js +29 -24
  32. package/lib/rules/no-restricted-exports.js +8 -8
  33. package/lib/rules/no-restricted-globals.js +1 -2
  34. package/lib/rules/no-restricted-imports.js +1 -2
  35. package/lib/rules/no-restricted-properties.js +2 -0
  36. package/lib/rules/no-restricted-syntax.js +2 -0
  37. package/lib/rules/no-shadow.js +1 -2
  38. package/lib/rules/no-unassigned-vars.js +1 -2
  39. package/lib/rules/no-unused-expressions.js +1 -2
  40. package/lib/rules/no-unused-vars.js +50 -53
  41. package/lib/rules/no-use-before-define.js +1 -2
  42. package/lib/rules/no-useless-constructor.js +1 -2
  43. package/lib/rules/no-var.js +1 -2
  44. package/lib/rules/object-shorthand.js +3 -1
  45. package/lib/rules/one-var.js +3 -1
  46. package/lib/rules/prefer-arrow-callback.js +19 -10
  47. package/lib/types/config-api.d.ts +2 -1
  48. package/lib/types/index.d.ts +23 -0
  49. package/package.json +9 -5
package/README.md CHANGED
@@ -315,8 +315,8 @@ Tanuj Kanti
315
315
  </a>
316
316
  </td><td align="center" valign="top" width="11%">
317
317
  <a href="https://github.com/lumirlumir">
318
- <img src="https://github.com/lumirlumir.png?s=75" width="75" height="75" alt="루밀LuMir's Avatar"><br />
319
- 루밀LuMir
318
+ <img src="https://github.com/lumirlumir.png?s=75" width="75" height="75" alt="lumir's Avatar"><br />
319
+ lumir
320
320
  </a>
321
321
  </td><td align="center" valign="top" width="11%">
322
322
  <a href="https://github.com/Pixel998">
@@ -360,7 +360,7 @@ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
360
360
  <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a></p><h3>Gold Sponsors</h3>
361
361
  <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a></p><h3>Silver Sponsors</h3>
362
362
  <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
363
- <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://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://www.crawljobs.com/"><img src="https://images.opencollective.com/crawljobs-poland/fa43a17/logo.png" alt="CrawlJobs" height="32"></a> <a href="https://depot.dev"><img src="https://images.opencollective.com/depot/39125a1/logo.png" alt="Depot" 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" alt="GitBook" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://citadel.co.jp"><img src="https://avatars.githubusercontent.com/u/75781367" alt="Citadel AI" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
363
+ <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://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://www.crawljobs.com/"><img src="https://images.opencollective.com/crawljobs-poland/fa43a17/logo.png" alt="CrawlJobs" height="32"></a> <a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://depot.dev"><img src="https://images.opencollective.com/depot/39125a1/logo.png" alt="Depot" 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" alt="GitBook" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://citadel.co.jp"><img src="https://avatars.githubusercontent.com/u/75781367" alt="Citadel AI" height="32"></a></p>
364
364
  <h3>Technology Sponsors</h3>
365
365
  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.
366
366
  <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>
package/bin/eslint.js CHANGED
@@ -61,6 +61,32 @@ function readStdin() {
61
61
  });
62
62
  }
63
63
 
64
+ /**
65
+ * Spawns an external command and propagates its exit status.
66
+ * @param {string} command The command to run.
67
+ * @param {string[]} args The command arguments.
68
+ * @throws {Error} If the command cannot be spawned.
69
+ * @returns {void}
70
+ */
71
+ function spawnExternalCommand(command, args) {
72
+ const spawn = require("cross-spawn");
73
+ const result = spawn.sync(command, args, {
74
+ encoding: "utf8",
75
+ stdio: "inherit",
76
+ });
77
+
78
+ if (result.error) {
79
+ throw result.error;
80
+ }
81
+
82
+ if (result.signal) {
83
+ process.kill(process.pid, result.signal);
84
+ return;
85
+ }
86
+
87
+ process.exitCode = result.status ?? 0;
88
+ }
89
+
64
90
  /**
65
91
  * Get the error message of a given value.
66
92
  * @param {any} error The value to get.
@@ -146,12 +172,7 @@ ${getErrorMessage(error)}`;
146
172
  "You can also run this command directly using 'npm init @eslint/config@latest'.",
147
173
  );
148
174
 
149
- const spawn = require("cross-spawn");
150
-
151
- spawn.sync("npm", ["init", "@eslint/config@latest"], {
152
- encoding: "utf8",
153
- stdio: "inherit",
154
- });
175
+ spawnExternalCommand("npm", ["init", "@eslint/config@latest"]);
155
176
  return;
156
177
  }
157
178
 
@@ -161,12 +182,7 @@ ${getErrorMessage(error)}`;
161
182
  "You can also run this command directly using 'npx @eslint/mcp@latest'.",
162
183
  );
163
184
 
164
- const spawn = require("cross-spawn");
165
-
166
- spawn.sync("npx", ["@eslint/mcp@latest"], {
167
- encoding: "utf8",
168
- stdio: "inherit",
169
- });
185
+ spawnExternalCommand("npx", ["@eslint/mcp@latest"]);
170
186
  return;
171
187
  }
172
188
 
package/lib/config-api.js CHANGED
@@ -4,9 +4,15 @@
4
4
  */
5
5
 
6
6
  "use strict";
7
- const { defineConfig, globalIgnores } = require("@eslint/config-helpers");
7
+
8
+ const {
9
+ defineConfig,
10
+ globalIgnores,
11
+ includeIgnoreFile,
12
+ } = require("@eslint/config-helpers");
8
13
 
9
14
  module.exports = {
10
15
  defineConfig,
11
16
  globalIgnores,
17
+ includeIgnoreFile,
12
18
  };
@@ -107,6 +107,34 @@ function createRulesMeta(rules) {
107
107
  }, {});
108
108
  }
109
109
 
110
+ /**
111
+ * Gets the replacement rule names from a deprecated rule's metadata.
112
+ * @param {RulesMeta} meta The rule metadata.
113
+ * @returns {string[]} Replacement rule names.
114
+ */
115
+ function getDeprecatedRuleReplacements(meta) {
116
+ if (typeof meta.deprecated !== "object") {
117
+ return meta.replacedBy || [];
118
+ }
119
+
120
+ const { replacedBy } = meta.deprecated;
121
+
122
+ if (!Array.isArray(replacedBy)) {
123
+ return [];
124
+ }
125
+
126
+ return replacedBy.map(replacement => {
127
+ if (typeof replacement !== "object" || replacement === null) {
128
+ return "";
129
+ }
130
+
131
+ const pluginName = replacement.plugin?.name;
132
+ const ruleName = replacement.rule?.name;
133
+
134
+ return `${typeof pluginName === "string" ? `${getShorthandName(pluginName, "eslint-plugin")}/` : ""}${typeof ruleName === "string" ? ruleName : ""}`;
135
+ });
136
+ }
137
+
110
138
  /** @type {WeakMap<CalculatedConfig, DeprecatedRuleInfo[]>} */
111
139
  const usedDeprecatedRulesCache = new WeakMap();
112
140
 
@@ -144,12 +172,7 @@ function getOrFindUsedDeprecatedRules(eslint, maybeFilePath) {
144
172
 
145
173
  retv.push({
146
174
  ruleId,
147
- replacedBy: usesNewFormat
148
- ? (meta.deprecated.replacedBy?.map(
149
- replacement =>
150
- `${replacement.plugin?.name !== void 0 ? `${getShorthandName(replacement.plugin.name, "eslint-plugin")}/` : ""}${replacement.rule?.name ?? ""}`,
151
- ) ?? [])
152
- : meta.replacedBy || [],
175
+ replacedBy: getDeprecatedRuleReplacements(meta),
153
176
  info: usesNewFormat ? meta.deprecated : void 0,
154
177
  });
155
178
  }
@@ -617,7 +617,7 @@ function processCodePathToExit(analyzer, node) {
617
617
 
618
618
  case "Identifier":
619
619
  if (isIdentifierReference(node)) {
620
- state.makeFirstThrowablePathInTryBlock();
620
+ state.makeFirstThrowablePathInTryOrCatchBlock();
621
621
  dontForward = true;
622
622
  }
623
623
  break;
@@ -626,7 +626,7 @@ function processCodePathToExit(analyzer, node) {
626
626
  case "ImportExpression":
627
627
  case "MemberExpression":
628
628
  case "NewExpression":
629
- state.makeFirstThrowablePathInTryBlock();
629
+ state.makeFirstThrowablePathInTryOrCatchBlock();
630
630
  break;
631
631
 
632
632
  case "YieldExpression":
@@ -1772,11 +1772,12 @@ class CodePathState {
1772
1772
  }
1773
1773
 
1774
1774
  /**
1775
- * Makes a code path segment from the first throwable node to the `catch`
1776
- * block or the `finally` block.
1775
+ * Makes a code path segment from the first throwable node in a `try` block to the `catch`
1776
+ * block or the `finally` block or from the first throwable node in a `catch` block
1777
+ * to the `finally` block.
1777
1778
  * @returns {void}
1778
1779
  */
1779
- makeFirstThrowablePathInTryBlock() {
1780
+ makeFirstThrowablePathInTryOrCatchBlock() {
1780
1781
  const forkContext = this.forkContext;
1781
1782
 
1782
1783
  if (!forkContext.reachable) {
@@ -1785,10 +1786,13 @@ class CodePathState {
1785
1786
 
1786
1787
  const context = getThrowContext(this);
1787
1788
 
1789
+ if (context === this || !context.thrownForkContext.empty) {
1790
+ return;
1791
+ }
1792
+
1788
1793
  if (
1789
- context === this ||
1790
- context.position !== "try" ||
1791
- !context.thrownForkContext.empty
1794
+ context.position !== "try" &&
1795
+ (context.position !== "catch" || !context.hasFinalizer)
1792
1796
  ) {
1793
1797
  return;
1794
1798
  }
@@ -45,6 +45,15 @@ function nodeToString(node, label) {
45
45
  }
46
46
  }
47
47
 
48
+ /**
49
+ * Escape text for use in a DOT label.
50
+ * @param {string} value The value to escape.
51
+ * @returns {string} The escaped value.
52
+ */
53
+ function escapeDotLabelText(value) {
54
+ return value.replace(/\\/gu, String.raw`\\`).replace(/"/gu, String.raw`\"`);
55
+ }
56
+
48
57
  //------------------------------------------------------------------------------
49
58
  // Public Interface
50
59
  //------------------------------------------------------------------------------
@@ -147,7 +156,9 @@ module.exports = {
147
156
  }
148
157
 
149
158
  if (segment.internal.nodes.length > 0) {
150
- text += segment.internal.nodes.join("\\n");
159
+ text += segment.internal.nodes
160
+ .map(escapeDotLabelText)
161
+ .join("\\n");
151
162
  } else {
152
163
  text += "????";
153
164
  }
@@ -131,6 +131,8 @@ module.exports = {
131
131
  },
132
132
  ],
133
133
 
134
+ defaultOptions: ["always"],
135
+
134
136
  messages: {
135
137
  unexpectedLowercaseComment:
136
138
  "Comments should not begin with a lowercase character.",
@@ -140,7 +142,7 @@ module.exports = {
140
142
  },
141
143
 
142
144
  create(context) {
143
- const capitalize = context.options[0] || "always",
145
+ const capitalize = context.options[0],
144
146
  normalizedOptions = getAllNormalizedOptions(context.options[1]),
145
147
  sourceCode = context.sourceCode;
146
148
 
@@ -18,8 +18,6 @@ const astUtils = require("./utils/ast-utils");
18
18
  /** @type {import('../types').Rule.RuleModule} */
19
19
  module.exports = {
20
20
  meta: {
21
- dialects: ["javascript", "typescript"],
22
- language: "javascript",
23
21
  type: "suggestion",
24
22
 
25
23
  defaultOptions: [
@@ -32,6 +30,7 @@ module.exports = {
32
30
 
33
31
  docs: {
34
32
  description: "Enforce that class methods utilize `this`",
33
+ dialects: ["JavaScript", "TypeScript"],
35
34
  recommended: false,
36
35
  url: "https://eslint.org/docs/latest/rules/class-methods-use-this",
37
36
  },
@@ -21,12 +21,11 @@ function isRequiredParameter(node) {
21
21
  /** @type {import('../types').Rule.RuleModule} */
22
22
  module.exports = {
23
23
  meta: {
24
- dialects: ["javascript", "typescript"],
25
- language: "javascript",
26
24
  type: "suggestion",
27
25
 
28
26
  docs: {
29
27
  description: "Enforce default parameters to be last",
28
+ dialects: ["JavaScript", "TypeScript"],
30
29
  recommended: false,
31
30
  frozen: true,
32
31
  url: "https://eslint.org/docs/latest/rules/default-param-last",
@@ -59,6 +59,8 @@ module.exports = {
59
59
  ],
60
60
  },
61
61
 
62
+ defaultOptions: ["always"],
63
+
62
64
  fixable: "code",
63
65
 
64
66
  messages: {
@@ -70,7 +72,7 @@ module.exports = {
70
72
  },
71
73
 
72
74
  create(context) {
73
- const config = context.options[0] || "always";
75
+ const config = context.options[0];
74
76
  const options = context.options[1] || {};
75
77
  const sourceCode = context.sourceCode;
76
78
 
@@ -117,6 +117,50 @@ module.exports = {
117
117
  }
118
118
  return 0;
119
119
  }
120
+ /**
121
+ * Collects all expressions that modify the counter.
122
+ * @param {ASTNode} node The expression node to check.
123
+ * @param {string} counter The name of the counter variable.
124
+ * @returns {ASTNode[]} An array of modifying expressions.
125
+ */
126
+ function getModifyingExpressions(node, counter) {
127
+ if (node.type === "SequenceExpression") {
128
+ return node.expressions.flatMap(expr =>
129
+ getModifyingExpressions(expr, counter),
130
+ );
131
+ }
132
+ if (
133
+ node.type === "UpdateExpression" &&
134
+ node.argument.type === "Identifier" &&
135
+ node.argument.name === counter
136
+ ) {
137
+ return [node];
138
+ }
139
+ if (
140
+ node.type === "AssignmentExpression" &&
141
+ node.left.type === "Identifier" &&
142
+ node.left.name === counter
143
+ ) {
144
+ return [node];
145
+ }
146
+ return [];
147
+ }
148
+
149
+ /**
150
+ * Determines the direction of a single update expression for the counter.
151
+ * @param {ASTNode} expr An expression node to check (UpdateExpression or AssignmentExpression).
152
+ * @param {string} counter The variable name of the counter.
153
+ * @returns {number} 1 if incrementing, -1 if decrementing, 0 if unknown or not modifying the counter.
154
+ */
155
+ function getDirectionFromExpression(expr, counter) {
156
+ if (expr.type === "UpdateExpression") {
157
+ return getUpdateDirection(expr, counter);
158
+ }
159
+ if (expr.type === "AssignmentExpression") {
160
+ return getAssignmentDirection(expr, counter);
161
+ }
162
+ return 0;
163
+ }
120
164
 
121
165
  return {
122
166
  ForStatement(node) {
@@ -146,17 +190,17 @@ module.exports = {
146
190
  return;
147
191
  }
148
192
 
149
- if (update.type === "UpdateExpression") {
150
- if (
151
- getUpdateDirection(update, counter) ===
152
- wrongDirection
153
- ) {
154
- report(node);
155
- }
156
- } else if (
157
- update.type === "AssignmentExpression" &&
158
- getAssignmentDirection(update, counter) ===
159
- wrongDirection
193
+ const mutatingExpressions = getModifyingExpressions(
194
+ update,
195
+ counter,
196
+ );
197
+
198
+ if (
199
+ mutatingExpressions.length === 1 &&
200
+ getDirectionFromExpression(
201
+ mutatingExpressions[0],
202
+ counter,
203
+ ) === wrongDirection
160
204
  ) {
161
205
  report(node);
162
206
  }
@@ -105,6 +105,8 @@ module.exports = {
105
105
  ],
106
106
  },
107
107
 
108
+ defaultOptions: ["always"],
109
+
108
110
  messages: {
109
111
  matchProperty:
110
112
  "Function name `{{funcName}}` should match property name `{{name}}`.",
@@ -11,8 +11,6 @@
11
11
  /** @type {import('../types').Rule.RuleModule} */
12
12
  module.exports = {
13
13
  meta: {
14
- dialects: ["javascript", "typescript"],
15
- language: "javascript",
16
14
  type: "suggestion",
17
15
 
18
16
  defaultOptions: [
@@ -27,6 +25,7 @@ module.exports = {
27
25
  docs: {
28
26
  description:
29
27
  "Enforce the consistent use of either `function` declarations or expressions assigned to variables",
28
+ dialects: ["JavaScript", "TypeScript"],
30
29
  recommended: false,
31
30
  frozen: true,
32
31
  url: "https://eslint.org/docs/latest/rules/func-style",
@@ -50,12 +50,11 @@ function isInitialized(node) {
50
50
  module.exports = {
51
51
  meta: {
52
52
  type: "suggestion",
53
- dialects: ["typescript", "javascript"],
54
- language: "javascript",
55
53
 
56
54
  docs: {
57
55
  description:
58
56
  "Require or disallow initialization in variable declarations",
57
+ dialects: ["JavaScript", "TypeScript"],
59
58
  recommended: false,
60
59
  frozen: true,
61
60
  url: "https://eslint.org/docs/latest/rules/init-declarations",
@@ -94,6 +93,9 @@ module.exports = {
94
93
  },
95
94
  ],
96
95
  },
96
+
97
+ defaultOptions: ["always"],
98
+
97
99
  messages: {
98
100
  initialized:
99
101
  "Variable '{{idName}}' should be initialized on declaration.",
@@ -103,10 +105,7 @@ module.exports = {
103
105
  },
104
106
 
105
107
  create(context) {
106
- const MODE_ALWAYS = "always",
107
- MODE_NEVER = "never";
108
-
109
- const mode = context.options[0] || MODE_ALWAYS;
108
+ const mode = context.options[0];
110
109
  const params = context.options[1] || {};
111
110
 
112
111
  // Track whether we're inside a declared namespace
@@ -145,10 +144,10 @@ module.exports = {
145
144
  params.ignoreForLoopInit && isForLoop(node.parent);
146
145
  let messageId = "";
147
146
 
148
- if (mode === MODE_ALWAYS && !initialized) {
147
+ if (mode === "always" && !initialized) {
149
148
  messageId = "initialized";
150
149
  } else if (
151
- mode === MODE_NEVER &&
150
+ mode === "never" &&
152
151
  !CONSTANT_BINDINGS.has(kind) &&
153
152
  initialized &&
154
153
  !isIgnoredForLoop
@@ -259,6 +259,9 @@ module.exports = {
259
259
  },
260
260
  ],
261
261
  },
262
+
263
+ defaultOptions: ["always"],
264
+
262
265
  fixable: "code",
263
266
  hasSuggestions: true,
264
267
  messages: {
@@ -281,7 +284,7 @@ module.exports = {
281
284
  },
282
285
 
283
286
  create(context) {
284
- const mode = context.options[0] === "never" ? "never" : "always";
287
+ const mode = context.options[0];
285
288
  const checkIf =
286
289
  mode === "always" &&
287
290
  context.options.length > 1 &&
@@ -47,16 +47,18 @@ module.exports = {
47
47
  },
48
48
  ],
49
49
 
50
+ defaultOptions: [1],
51
+
50
52
  messages: {
51
53
  maximumExceeded:
52
54
  "File has too many classes ({{ classCount }}). Maximum allowed is {{ max }}.",
53
55
  },
54
56
  },
55
57
  create(context) {
56
- const [option = {}] = context.options;
58
+ const option = context.options[0];
57
59
  const [ignoreExpressions, max] =
58
60
  typeof option === "number"
59
- ? [false, option || 1]
61
+ ? [false, option]
60
62
  : [option.ignoreExpressions, option.max || 1];
61
63
 
62
64
  let classCount = 0;
@@ -44,6 +44,9 @@ module.exports = {
44
44
  ],
45
45
  },
46
46
  ],
47
+
48
+ defaultOptions: [4],
49
+
47
50
  messages: {
48
51
  tooDeeply:
49
52
  "Blocks are nested too deeply ({{depth}}). Maximum allowed is {{maxDepth}}.",
@@ -78,6 +78,9 @@ module.exports = {
78
78
  },
79
79
 
80
80
  schema: [OPTIONS_OR_INTEGER_SCHEMA],
81
+
82
+ defaultOptions: [50],
83
+
81
84
  messages: {
82
85
  exceed: "{{name}} has too many lines ({{lineCount}}). Maximum allowed is {{maxLines}}.",
83
86
  },
@@ -65,6 +65,9 @@ module.exports = {
65
65
  ],
66
66
  },
67
67
  ],
68
+
69
+ defaultOptions: [300],
70
+
68
71
  messages: {
69
72
  exceed: "File has too many lines ({{actual}}). Maximum allowed is {{max}}.",
70
73
  },
@@ -44,6 +44,9 @@ module.exports = {
44
44
  ],
45
45
  },
46
46
  ],
47
+
48
+ defaultOptions: [10],
49
+
47
50
  messages: {
48
51
  exceed: "Too many nested callbacks ({{num}}). Maximum allowed is {{max}}.",
49
52
  },
@@ -20,12 +20,11 @@ const { upperCaseFirst } = require("../shared/string-utils");
20
20
  module.exports = {
21
21
  meta: {
22
22
  type: "suggestion",
23
- dialects: ["typescript", "javascript"],
24
- language: "javascript",
25
23
 
26
24
  docs: {
27
25
  description:
28
26
  "Enforce a maximum number of parameters in function definitions",
27
+ dialects: ["JavaScript", "TypeScript"],
29
28
  recommended: false,
30
29
  url: "https://eslint.org/docs/latest/rules/max-params",
31
30
  },
@@ -65,6 +64,9 @@ module.exports = {
65
64
  ],
66
65
  },
67
66
  ],
67
+
68
+ defaultOptions: [3],
69
+
68
70
  messages: {
69
71
  exceed: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}.",
70
72
  },
@@ -61,6 +61,9 @@ module.exports = {
61
61
  additionalProperties: false,
62
62
  },
63
63
  ],
64
+
65
+ defaultOptions: [10],
66
+
64
67
  messages: {
65
68
  exceed: "{{name}} has too many statements ({{count}}). Maximum allowed is {{max}}.",
66
69
  },
@@ -24,12 +24,11 @@ const {
24
24
  /** @type {import('../types').Rule.RuleModule} */
25
25
  module.exports = {
26
26
  meta: {
27
- dialects: ["javascript", "typescript"],
28
- language: "javascript",
29
27
  type: "suggestion",
30
28
 
31
29
  docs: {
32
30
  description: "Disallow `Array` constructors",
31
+ dialects: ["JavaScript", "TypeScript"],
33
32
  recommended: false,
34
33
  url: "https://eslint.org/docs/latest/rules/no-array-constructor",
35
34
  },
@@ -15,11 +15,10 @@ const astUtils = require("./utils/ast-utils");
15
15
  module.exports = {
16
16
  meta: {
17
17
  type: "problem",
18
- dialects: ["javascript", "typescript"],
19
- language: "javascript",
20
18
 
21
19
  docs: {
22
20
  description: "Disallow duplicate class members",
21
+ dialects: ["JavaScript", "TypeScript"],
23
22
  recommended: true,
24
23
  url: "https://eslint.org/docs/latest/rules/no-dupe-class-members",
25
24
  },
@@ -294,8 +294,6 @@ function handleImportsExports(
294
294
  /** @type {import('../types').Rule.RuleModule} */
295
295
  module.exports = {
296
296
  meta: {
297
- dialects: ["javascript", "typescript"],
298
- language: "javascript",
299
297
  type: "problem",
300
298
 
301
299
  defaultOptions: [
@@ -307,6 +305,7 @@ module.exports = {
307
305
 
308
306
  docs: {
309
307
  description: "Disallow duplicate module imports",
308
+ dialects: ["JavaScript", "TypeScript"],
310
309
  recommended: false,
311
310
  url: "https://eslint.org/docs/latest/rules/no-duplicate-imports",
312
311
  },
@@ -103,8 +103,6 @@ function isParameterPropertiesConstructor(node) {
103
103
  /** @type {import('../types').Rule.RuleModule} */
104
104
  module.exports = {
105
105
  meta: {
106
- dialects: ["javascript", "typescript"],
107
- language: "javascript",
108
106
  hasSuggestions: true,
109
107
  type: "suggestion",
110
108
 
@@ -112,6 +110,7 @@ module.exports = {
112
110
 
113
111
  docs: {
114
112
  description: "Disallow empty functions",
113
+ dialects: ["JavaScript", "TypeScript"],
115
114
  recommended: false,
116
115
  url: "https://eslint.org/docs/latest/rules/no-empty-function",
117
116
  },
@@ -36,8 +36,6 @@ function isCodePathWithLexicalThis(codePath, node) {
36
36
  /** @type {import('../types').Rule.RuleModule} */
37
37
  module.exports = {
38
38
  meta: {
39
- dialects: ["javascript", "typescript"],
40
- language: "javascript",
41
39
  type: "suggestion",
42
40
 
43
41
  defaultOptions: [{ capIsConstructor: true }],
@@ -45,6 +43,7 @@ module.exports = {
45
43
  docs: {
46
44
  description:
47
45
  "Disallow use of `this` in contexts where the value of `this` is `undefined`",
46
+ dialects: ["JavaScript", "TypeScript"],
48
47
  recommended: false,
49
48
  url: "https://eslint.org/docs/latest/rules/no-invalid-this",
50
49
  },