eslint 9.37.0 → 9.39.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.
package/README.md CHANGED
@@ -287,6 +287,11 @@ fnx
287
287
  Josh Goldberg ✨
288
288
  </a>
289
289
  </td><td align="center" valign="top" width="11%">
290
+ <a href="https://github.com/SwetaTanwar">
291
+ <img src="https://github.com/SwetaTanwar.png?s=75" width="75" height="75" alt="Sweta Tanwar's Avatar"><br />
292
+ Sweta Tanwar
293
+ </a>
294
+ </td><td align="center" valign="top" width="11%">
290
295
  <a href="https://github.com/Tanujkanti4441">
291
296
  <img src="https://github.com/Tanujkanti4441.png?s=75" width="75" height="75" alt="Tanuj Kanti's Avatar"><br />
292
297
  Tanuj Kanti
@@ -296,6 +301,11 @@ Tanuj Kanti
296
301
  <img src="https://github.com/lumirlumir.png?s=75" width="75" height="75" alt="루밀LuMir's Avatar"><br />
297
302
  루밀LuMir
298
303
  </a>
304
+ </td><td align="center" valign="top" width="11%">
305
+ <a href="https://github.com/Pixel998">
306
+ <img src="https://github.com/Pixel998.png?s=75" width="75" height="75" alt="Pixel998's Avatar"><br />
307
+ Pixel998
308
+ </a>
299
309
  </td></tr></tbody></table>
300
310
 
301
311
  ### Website Team
@@ -332,8 +342,8 @@ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
332
342
  <h3>Platinum Sponsors</h3>
333
343
  <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>
334
344
  <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
335
- <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" 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" alt="American Express" 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>
336
- <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://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://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
345
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/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://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" 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>
346
+ <p><a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" 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://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
337
347
  <h3>Technology Sponsors</h3>
338
348
  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.
339
349
  <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>
@@ -506,7 +506,7 @@ async function globMultiSearch({
506
506
  * @param {boolean} args.globInputPaths true to interpret glob patterns,
507
507
  * false to not interpret glob patterns.
508
508
  * @param {string} args.cwd The current working directory to find from.
509
- * @param {ConfigLoader|LegacyConfigLoader} args.configLoader The config loeader for the current run.
509
+ * @param {ConfigLoader|LegacyConfigLoader} args.configLoader The config loader for the current run.
510
510
  * @param {boolean} args.errorOnUnmatchedPattern Determines if an unmatched pattern
511
511
  * should throw an error.
512
512
  * @returns {Promise<Array<string>>} The fully resolved file paths.
@@ -17,6 +17,7 @@ const { pathToFileURL } = require("node:url");
17
17
  const { SHARE_ENV, Worker } = require("node:worker_threads");
18
18
  const { version } = require("../../package.json");
19
19
  const { defaultConfig } = require("../config/default-config");
20
+ const timing = require("../linter/timing");
20
21
 
21
22
  const {
22
23
  createDebug,
@@ -503,6 +504,11 @@ async function runWorkers(
503
504
  worstNetLintingRatio,
504
505
  netLintingRatio,
505
506
  );
507
+
508
+ if (timing.enabled && indexedResults.timings) {
509
+ timing.mergeData(indexedResults.timings);
510
+ }
511
+
506
512
  for (const result of indexedResults) {
507
513
  const { index } = result;
508
514
  delete result.index;
@@ -522,7 +528,17 @@ async function runWorkers(
522
528
  for (let index = 0; index < workerCount; ++index) {
523
529
  promises[index] = new Promise(workerExecutor);
524
530
  }
525
- await Promise.all(promises);
531
+
532
+ try {
533
+ await Promise.all(promises);
534
+ } catch (error) {
535
+ /*
536
+ * If any worker fails, suppress timing display in the main thread
537
+ * to avoid printing partial or misleading timing output.
538
+ */
539
+ timing.disableDisplay();
540
+ throw error;
541
+ }
526
542
 
527
543
  if (worstNetLintingRatio < LOW_NET_LINTING_RATIO) {
528
544
  warnOnLowNetLintingRatio();
@@ -29,6 +29,7 @@ const {
29
29
  processOptions,
30
30
  } = require("./eslint-helpers");
31
31
  const { WarningService } = require("../services/warning-service");
32
+ const timing = require("../linter/timing");
32
33
 
33
34
  const depsLoadedTime = hrtimeBigint();
34
35
 
@@ -39,7 +40,7 @@ const depsLoadedTime = hrtimeBigint();
39
40
  /** @typedef {import("../types").ESLint.LintResult} LintResult */
40
41
  /** @typedef {import("../types").ESLint.Options} ESLintOptions */
41
42
  /** @typedef {LintResult & { index?: number; }} IndexedLintResult */
42
- /** @typedef {IndexedLintResult[] & { netLintingDuration: bigint; }} WorkerLintResults */
43
+ /** @typedef {IndexedLintResult[] & { netLintingDuration: bigint; timings?: Record<string, number>; }} WorkerLintResults */
43
44
  /**
44
45
  * @typedef {Object} WorkerData - Data passed to the worker thread.
45
46
  * @property {ESLintOptions | string} eslintOptionsOrURL - The unprocessed ESLint options or the URL of the options module.
@@ -57,6 +58,12 @@ const debug = createDebug(`eslint:worker:thread-${threadId}`);
57
58
  // Main
58
59
  //------------------------------------------------------------------------------
59
60
 
61
+ /*
62
+ * Prevent timing module from printing profiling output from worker threads.
63
+ * The main thread is responsible for displaying any aggregated timings.
64
+ */
65
+ timing.disableDisplay();
66
+
60
67
  debug("Dependencies loaded in %t", depsLoadedTime - startTime);
61
68
 
62
69
  (async () => {
@@ -158,5 +165,9 @@ debug("Dependencies loaded in %t", depsLoadedTime - startTime);
158
165
  indexedResults.netLintingDuration =
159
166
  lintingDuration - loadConfigTotalDuration - readFileCounter.duration;
160
167
 
168
+ if (timing.enabled) {
169
+ indexedResults.timings = timing.getData();
170
+ }
171
+
161
172
  parentPort.postMessage(indexedResults);
162
173
  })();
@@ -426,7 +426,7 @@ function validateSuggestions(suggest, messages) {
426
426
 
427
427
  if (typeof suggestion.fix !== "function") {
428
428
  throw new TypeError(
429
- `context.report() called with a suggest option without a fix function. See: ${suggestion}`,
429
+ `context.report() called with a suggest option without a fix function. See: ${JSON.stringify(suggestion, null, 2)}`,
430
430
  );
431
431
  }
432
432
  });
@@ -17,8 +17,9 @@ const vk = require("eslint-visitor-keys");
17
17
  //-----------------------------------------------------------------------------
18
18
 
19
19
  /**
20
- * @import { ESQueryParsedSelector } from "./esquery.js";
21
20
  * @import { Language, SourceCode } from "@eslint/core";
21
+ * @import { ESQueryOptions } from "esquery";
22
+ * @import { ESQueryParsedSelector } from "./esquery.js";
22
23
  * @import { SourceCodeVisitor } from "./source-code-visitor.js";
23
24
  */
24
25
 
@@ -47,11 +48,10 @@ class ESQueryHelper {
47
48
  * Creates a new instance.
48
49
  * @param {SourceCodeVisitor} visitor The visitor containing the functions to call.
49
50
  * @param {ESQueryOptions} esqueryOptions `esquery` options for traversing custom nodes.
50
- * @returns {NodeEventGenerator} new instance
51
51
  */
52
52
  constructor(visitor, esqueryOptions) {
53
53
  /**
54
- * The emitter to use during traversal.
54
+ * The visitor to use during traversal.
55
55
  * @type {SourceCodeVisitor}
56
56
  */
57
57
  this.visitor = visitor;
@@ -288,7 +288,10 @@ class SourceCodeTraverser {
288
288
  false,
289
289
  )
290
290
  .forEach(selector => {
291
- visitor.callSync(selector, step.target);
291
+ visitor.callSync(
292
+ selector,
293
+ ...(step.args ?? [step.target]),
294
+ );
292
295
  });
293
296
  currentAncestry.unshift(step.target);
294
297
  } else {
@@ -300,7 +303,10 @@ class SourceCodeTraverser {
300
303
  true,
301
304
  )
302
305
  .forEach(selector => {
303
- visitor.callSync(selector, step.target);
306
+ visitor.callSync(
307
+ selector,
308
+ ...(step.args ?? [step.target]),
309
+ );
304
310
  });
305
311
  }
306
312
  } catch (err) {
@@ -131,6 +131,7 @@ function display(data) {
131
131
  /* c8 ignore next */
132
132
  module.exports = (function () {
133
133
  const data = Object.create(null);
134
+ let displayEnabled = true;
134
135
 
135
136
  /**
136
137
  * Time the run
@@ -158,9 +159,42 @@ module.exports = (function () {
158
159
  };
159
160
  }
160
161
 
162
+ /**
163
+ * Returns a shallow copy of the collected timings data.
164
+ * @returns {Record<string, number>} mapping of ruleId to total time in ms
165
+ */
166
+ function getData() {
167
+ return { ...data };
168
+ }
169
+
170
+ /**
171
+ * Merges rule timing totals collected elsewhere into this process' totals.
172
+ * @param {Record<string, number>} dataToMerge mapping of ruleId to total time in ms
173
+ * @returns {void}
174
+ */
175
+ function mergeData(dataToMerge) {
176
+ for (const [key, value] of Object.entries(dataToMerge)) {
177
+ if (typeof data[key] === "undefined") {
178
+ data[key] = 0;
179
+ }
180
+ data[key] += value;
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Disables printing of timing data on process exit.
186
+ * Intended for worker threads or non-main contexts.
187
+ * @returns {void}
188
+ */
189
+ function disableDisplay() {
190
+ displayEnabled = false;
191
+ }
192
+
161
193
  if (enabled) {
162
194
  process.on("exit", () => {
163
- display(data);
195
+ if (displayEnabled && Object.keys(data).length > 0) {
196
+ display(data);
197
+ }
164
198
  });
165
199
  }
166
200
 
@@ -168,5 +202,8 @@ module.exports = (function () {
168
202
  time,
169
203
  enabled,
170
204
  getListSize,
205
+ getData,
206
+ mergeData,
207
+ disableDisplay,
171
208
  };
172
209
  })();
@@ -16,7 +16,7 @@ module.exports = {
16
16
  message: "Node.js rules were moved out of ESLint core.",
17
17
  url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
18
18
  deprecatedSince: "7.0.0",
19
- availableUntil: null,
19
+ availableUntil: "11.0.0",
20
20
  replacedBy: [
21
21
  {
22
22
  message:
@@ -68,6 +68,7 @@ module.exports = {
68
68
  },
69
69
 
70
70
  create(context) {
71
+ const sourceCode = context.sourceCode;
71
72
  const option = context.options[0];
72
73
  let threshold = THRESHOLD_DEFAULT;
73
74
  let VARIANT = "classic";
@@ -171,17 +172,21 @@ module.exports = {
171
172
 
172
173
  if (complexity > threshold) {
173
174
  let name;
175
+ let loc = node.loc;
174
176
 
175
177
  if (codePath.origin === "class-field-initializer") {
176
178
  name = "class field initializer";
177
179
  } else if (codePath.origin === "class-static-block") {
178
180
  name = "class static block";
181
+ loc = sourceCode.getFirstToken(node).loc;
179
182
  } else {
180
183
  name = astUtils.getFunctionNameWithKind(node);
184
+ loc = astUtils.getFunctionHeadLoc(node, sourceCode);
181
185
  }
182
186
 
183
187
  context.report({
184
188
  node,
189
+ loc,
185
190
  messageId: "complex",
186
191
  data: {
187
192
  name: upperCaseFirst(name),
@@ -46,7 +46,10 @@ module.exports = {
46
46
  */
47
47
  function report(node) {
48
48
  context.report({
49
- node,
49
+ loc: {
50
+ start: node.loc.start,
51
+ end: sourceCode.getTokenBefore(node.body).loc.end,
52
+ },
50
53
  messageId: "incorrectDirection",
51
54
  });
52
55
  }
@@ -60,7 +60,7 @@ module.exports = {
60
60
  message: "Node.js rules were moved out of ESLint core.",
61
61
  url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
62
62
  deprecatedSince: "7.0.0",
63
- availableUntil: null,
63
+ availableUntil: "11.0.0",
64
64
  replacedBy: [
65
65
  {
66
66
  message:
@@ -17,7 +17,7 @@ module.exports = {
17
17
  message: "Node.js rules were moved out of ESLint core.",
18
18
  url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
19
19
  deprecatedSince: "7.0.0",
20
- availableUntil: null,
20
+ availableUntil: "11.0.0",
21
21
  replacedBy: [
22
22
  {
23
23
  message:
@@ -101,7 +101,7 @@ module.exports = {
101
101
  message: "The rule was renamed.",
102
102
  url: "https://eslint.org/blog/2020/07/eslint-v7.5.0-released/#deprecating-id-blacklist",
103
103
  deprecatedSince: "7.5.0",
104
- availableUntil: null,
104
+ availableUntil: "11.0.0",
105
105
  replacedBy: [
106
106
  {
107
107
  rule: {
@@ -16,7 +16,7 @@ module.exports = {
16
16
  message: "Node.js rules were moved out of ESLint core.",
17
17
  url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
18
18
  deprecatedSince: "7.0.0",
19
- availableUntil: null,
19
+ availableUntil: "11.0.0",
20
20
  replacedBy: [
21
21
  {
22
22
  message:
@@ -32,7 +32,7 @@ module.exports = {
32
32
  message: "This rule was renamed.",
33
33
  url: "https://eslint.org/blog/2018/07/eslint-v5.1.0-released/",
34
34
  deprecatedSince: "5.1.0",
35
- availableUntil: null,
35
+ availableUntil: "11.0.0",
36
36
  replacedBy: [
37
37
  {
38
38
  rule: {
@@ -5,6 +5,12 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const astUtils = require("./utils/ast-utils");
13
+
8
14
  //------------------------------------------------------------------------------
9
15
  // Rule Definition
10
16
  //------------------------------------------------------------------------------
@@ -58,10 +64,15 @@ module.exports = {
58
64
 
59
65
  // Checks and reports duplications.
60
66
  const defs = variable.defs.filter(isParameter);
67
+ const loc = {
68
+ start: astUtils.getOpeningParenOfParams(node, sourceCode)
69
+ .loc.start,
70
+ end: sourceCode.getTokenBefore(node.body).loc.end,
71
+ };
61
72
 
62
73
  if (defs.length >= 2) {
63
74
  context.report({
64
- node,
75
+ loc,
65
76
  messageId: "unexpected",
66
77
  data: { name: variable.name },
67
78
  });
@@ -106,7 +106,7 @@ module.exports = {
106
106
 
107
107
  if (isDuplicate) {
108
108
  context.report({
109
- node,
109
+ loc: node.key.loc,
110
110
  messageId: "unexpected",
111
111
  data: { name },
112
112
  });