This commit is contained in:
2026-03-15 12:22:42 +01:00
parent cd99275933
commit 311ba5e7f3
558 changed files with 55182 additions and 22981 deletions

View File

@@ -90,7 +90,7 @@ class ESQueryParsedSelector {
}
/**
* Compares this selector's specifity to another selector for sorting purposes.
* Compares this selector's specificity to another selector for sorting purposes.
* @param {ESQueryParsedSelector} otherSelector The selector to compare against
* @returns {number}
* a value less than 0 if this selector is less specific than otherSelector

View File

@@ -426,7 +426,7 @@ function validateSuggestions(suggest, messages) {
if (typeof suggestion.fix !== "function") {
throw new TypeError(
`context.report() called with a suggest option without a fix function. See: ${suggestion}`,
`context.report() called with a suggest option without a fix function. See: ${JSON.stringify(suggestion, null, 2)}`,
);
}
});

View File

@@ -1921,6 +1921,20 @@ class Linter {
});
}
} else {
if (config.language === jslang) {
for (const comment of sourceCode.getInlineConfigNodes()) {
const { label } = commentParser.parseDirective(
comment.value,
);
if (label === "eslint-env") {
slots.warningService.emitESLintEnvWarning(
options.filename,
comment.loc.start.line,
);
}
}
}
const inlineConfigResult = sourceCode.applyInlineConfig?.();
if (inlineConfigResult) {

View File

@@ -17,8 +17,9 @@ const vk = require("eslint-visitor-keys");
//-----------------------------------------------------------------------------
/**
* @import { ESQueryParsedSelector } from "./esquery.js";
* @import { Language, SourceCode } from "@eslint/core";
* @import { ESQueryOptions } from "esquery";
* @import { ESQueryParsedSelector } from "./esquery.js";
* @import { SourceCodeVisitor } from "./source-code-visitor.js";
*/
@@ -47,11 +48,10 @@ class ESQueryHelper {
* Creates a new instance.
* @param {SourceCodeVisitor} visitor The visitor containing the functions to call.
* @param {ESQueryOptions} esqueryOptions `esquery` options for traversing custom nodes.
* @returns {NodeEventGenerator} new instance
*/
constructor(visitor, esqueryOptions) {
/**
* The emitter to use during traversal.
* The visitor to use during traversal.
* @type {SourceCodeVisitor}
*/
this.visitor = visitor;
@@ -288,7 +288,10 @@ class SourceCodeTraverser {
false,
)
.forEach(selector => {
visitor.callSync(selector, step.target);
visitor.callSync(
selector,
...(step.args ?? [step.target]),
);
});
currentAncestry.unshift(step.target);
} else {
@@ -300,7 +303,10 @@ class SourceCodeTraverser {
true,
)
.forEach(selector => {
visitor.callSync(selector, step.target);
visitor.callSync(
selector,
...(step.args ?? [step.target]),
);
});
}
} catch (err) {

View File

@@ -131,6 +131,7 @@ function display(data) {
/* c8 ignore next */
module.exports = (function () {
const data = Object.create(null);
let displayEnabled = true;
/**
* Time the run
@@ -158,9 +159,42 @@ module.exports = (function () {
};
}
/**
* Returns a shallow copy of the collected timings data.
* @returns {Record<string, number>} mapping of ruleId to total time in ms
*/
function getData() {
return { ...data };
}
/**
* Merges rule timing totals collected elsewhere into this process' totals.
* @param {Record<string, number>} dataToMerge mapping of ruleId to total time in ms
* @returns {void}
*/
function mergeData(dataToMerge) {
for (const [key, value] of Object.entries(dataToMerge)) {
if (typeof data[key] === "undefined") {
data[key] = 0;
}
data[key] += value;
}
}
/**
* Disables printing of timing data on process exit.
* Intended for worker threads or non-main contexts.
* @returns {void}
*/
function disableDisplay() {
displayEnabled = false;
}
if (enabled) {
process.on("exit", () => {
display(data);
if (displayEnabled && Object.keys(data).length > 0) {
display(data);
}
});
}
@@ -168,5 +202,8 @@ module.exports = (function () {
time,
enabled,
getListSize,
getData,
mergeData,
disableDisplay,
};
})();