Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2024-09-16 17:29:58 +00:00
parent 1afca056e3
commit 6989ba7bd2
3942 changed files with 55190 additions and 132206 deletions

View file

@ -19,6 +19,11 @@ const jsPlugin = require("@eslint/js");
// Helpers
//-----------------------------------------------------------------------------
/**
* Fields that are considered metadata and not part of the config object.
*/
const META_FIELDS = new Set(["name"]);
const ruleValidator = new RuleValidator();
/**
@ -75,7 +80,53 @@ function getObjectId(object) {
return name;
}
/**
* Wraps a config error with details about where the error occurred.
* @param {Error} error The original error.
* @param {number} originalLength The original length of the config array.
* @param {number} baseLength The length of the base config.
* @returns {TypeError} The new error with details.
*/
function wrapConfigErrorWithDetails(error, originalLength, baseLength) {
let location = "user-defined";
let configIndex = error.index;
/*
* A config array is set up in this order:
* 1. Base config
* 2. Original configs
* 3. User-defined configs
* 4. CLI-defined configs
*
* So we need to adjust the index to account for the base config.
*
* - If the index is less than the base length, it's in the base config
* (as specified by `baseConfig` argument to `FlatConfigArray` constructor).
* - If the index is greater than the base length but less than the original
* length + base length, it's in the original config. The original config
* is passed to the `FlatConfigArray` constructor as the first argument.
* - Otherwise, it's in the user-defined config, which is loaded from the
* config file and merged with any command-line options.
*/
if (error.index < baseLength) {
location = "base";
} else if (error.index < originalLength + baseLength) {
location = "original";
configIndex = error.index - baseLength;
} else {
configIndex = error.index - originalLength - baseLength;
}
return new TypeError(
`${error.message.slice(0, -1)} at ${location} index ${configIndex}.`,
{ cause: error }
);
}
const originalBaseConfig = Symbol("originalBaseConfig");
const originalLength = Symbol("originalLength");
const baseLength = Symbol("baseLength");
//-----------------------------------------------------------------------------
// Exports
@ -102,12 +153,24 @@ class FlatConfigArray extends ConfigArray {
schema: flatConfigSchema
});
/**
* The original length of the array before any modifications.
* @type {number}
*/
this[originalLength] = this.length;
if (baseConfig[Symbol.iterator]) {
this.unshift(...baseConfig);
} else {
this.unshift(baseConfig);
}
/**
* The length of the array after applying the base config.
* @type {number}
*/
this[baseLength] = this.length - this[originalLength];
/**
* The base config used to build the config array.
* @type {Array<FlatConfig>}
@ -125,6 +188,49 @@ class FlatConfigArray extends ConfigArray {
Object.defineProperty(this, "shouldIgnore", { writable: false });
}
/**
* Normalizes the array by calling the superclass method and catching/rethrowing
* any ConfigError exceptions with additional details.
* @param {any} [context] The context to use to normalize the array.
* @returns {Promise<FlatConfigArray>} A promise that resolves when the array is normalized.
*/
normalize(context) {
return super.normalize(context)
.catch(error => {
if (error.name === "ConfigError") {
throw wrapConfigErrorWithDetails(error, this[originalLength], this[baseLength]);
}
throw error;
});
}
/**
* Normalizes the array by calling the superclass method and catching/rethrowing
* any ConfigError exceptions with additional details.
* @param {any} [context] The context to use to normalize the array.
* @returns {FlatConfigArray} The current instance.
* @throws {TypeError} If the config is invalid.
*/
normalizeSync(context) {
try {
return super.normalizeSync(context);
} catch (error) {
if (error.name === "ConfigError") {
throw wrapConfigErrorWithDetails(error, this[originalLength], this[baseLength]);
}
throw error;
}
}
/* eslint-disable class-methods-use-this -- Desired as instance method */
/**
* Replaces a config with another config to allow us to put strings
@ -155,15 +261,15 @@ class FlatConfigArray extends ConfigArray {
}
/*
* If `shouldIgnore` is false, we remove any ignore patterns specified
* in the config so long as it's not a default config and it doesn't
* have a `files` entry.
* If a config object has `ignores` and no other non-meta fields, then it's an object
* for global ignores. If `shouldIgnore` is false, that object shouldn't apply,
* so we'll remove its `ignores`.
*/
if (
!this.shouldIgnore &&
!this[originalBaseConfig].includes(config) &&
config.ignores &&
!config.files
Object.keys(config).filter(key => !META_FIELDS.has(key)).length === 1
) {
/* eslint-disable-next-line no-unused-vars -- need to strip off other keys */
const { ignores, ...otherKeys } = config;

View file

@ -15,7 +15,6 @@ const fsp = fs.promises;
const isGlob = require("is-glob");
const hash = require("../cli-engine/hash");
const minimatch = require("minimatch");
const util = require("util");
const fswalk = require("@nodelib/fs.walk");
const globParent = require("glob-parent");
const isPathInside = require("is-path-inside");
@ -24,7 +23,6 @@ const isPathInside = require("is-path-inside");
// Fixup references
//-----------------------------------------------------------------------------
const doFsWalk = util.promisify(fswalk.walk);
const Minimatch = minimatch.Minimatch;
const MINIMATCH_OPTIONS = { dot: true };
@ -270,56 +268,92 @@ async function globSearch({
*/
const unmatchedPatterns = new Set([...relativeToPatterns.keys()]);
const filePaths = (await doFsWalk(basePath, {
const filePaths = (await new Promise((resolve, reject) => {
deepFilter(entry) {
const relativePath = normalizeToPosix(path.relative(basePath, entry.path));
const matchesPattern = matchers.some(matcher => matcher.match(relativePath, true));
let promiseRejected = false;
return matchesPattern && !configs.isDirectoryIgnored(entry.path);
},
entryFilter(entry) {
const relativePath = normalizeToPosix(path.relative(basePath, entry.path));
/**
* Wraps a boolean-returning filter function. The wrapped function will reject the promise if an error occurs.
* @param {Function} filter A filter function to wrap.
* @returns {Function} A function similar to the wrapped filter that rejects the promise if an error occurs.
*/
function wrapFilter(filter) {
return (...args) => {
// entries may be directories or files so filter out directories
if (entry.dirent.isDirectory()) {
return false;
}
/*
* Optimization: We need to track when patterns are left unmatched
* and so we use `unmatchedPatterns` to do that. There is a bit of
* complexity here because the same file can be matched by more than
* one pattern. So, when we start, we actually need to test every
* pattern against every file. Once we know there are no remaining
* unmatched patterns, then we can switch to just looking for the
* first matching pattern for improved speed.
*/
const matchesPattern = unmatchedPatterns.size > 0
? matchers.reduce((previousValue, matcher) => {
const pathMatches = matcher.match(relativePath);
/*
* We updated the unmatched patterns set only if the path
* matches and the file isn't ignored. If the file is
* ignored, that means there wasn't a match for the
* pattern so it should not be removed.
*
* Performance note: isFileIgnored() aggressively caches
* results so there is no performance penalty for calling
* it twice with the same argument.
*/
if (pathMatches && !configs.isFileIgnored(entry.path)) {
unmatchedPatterns.delete(matcher.pattern);
// No need to run the filter if an error has been thrown.
if (!promiseRejected) {
try {
return filter(...args);
} catch (error) {
promiseRejected = true;
reject(error);
}
return pathMatches || previousValue;
}, false)
: matchers.some(matcher => matcher.match(relativePath));
return matchesPattern && !configs.isFileIgnored(entry.path);
}
return false;
};
}
fswalk.walk(
basePath,
{
deepFilter: wrapFilter(entry => {
const relativePath = normalizeToPosix(path.relative(basePath, entry.path));
const matchesPattern = matchers.some(matcher => matcher.match(relativePath, true));
return matchesPattern && !configs.isDirectoryIgnored(entry.path);
}),
entryFilter: wrapFilter(entry => {
const relativePath = normalizeToPosix(path.relative(basePath, entry.path));
// entries may be directories or files so filter out directories
if (entry.dirent.isDirectory()) {
return false;
}
/*
* Optimization: We need to track when patterns are left unmatched
* and so we use `unmatchedPatterns` to do that. There is a bit of
* complexity here because the same file can be matched by more than
* one pattern. So, when we start, we actually need to test every
* pattern against every file. Once we know there are no remaining
* unmatched patterns, then we can switch to just looking for the
* first matching pattern for improved speed.
*/
const matchesPattern = unmatchedPatterns.size > 0
? matchers.reduce((previousValue, matcher) => {
const pathMatches = matcher.match(relativePath);
/*
* We updated the unmatched patterns set only if the path
* matches and the file isn't ignored. If the file is
* ignored, that means there wasn't a match for the
* pattern so it should not be removed.
*
* Performance note: isFileIgnored() aggressively caches
* results so there is no performance penalty for calling
* it twice with the same argument.
*/
if (pathMatches && !configs.isFileIgnored(entry.path)) {
unmatchedPatterns.delete(matcher.pattern);
}
return pathMatches || previousValue;
}, false)
: matchers.some(matcher => matcher.match(relativePath));
return matchesPattern && !configs.isFileIgnored(entry.path);
})
},
(error, entries) => {
// If the promise is already rejected, calling `resolve` or `reject` will do nothing.
if (error) {
reject(error);
} else {
resolve(entries);
}
}
);
})).map(entry => entry.path);
// now check to see if we have any unmatched patterns
@ -450,7 +484,7 @@ async function globMultiSearch({ searches, configs, errorOnUnmatchedPattern }) {
}
return [...new Set(filePaths)];
return filePaths;
}
@ -499,10 +533,7 @@ async function findFiles({
// files are added directly to the list
if (stat.isFile()) {
results.push({
filePath,
ignored: configs.isFileIgnored(filePath)
});
results.push(filePath);
}
// directories need extensions attached
@ -560,11 +591,10 @@ async function findFiles({
});
return [
...results,
...globbyResults.map(filePath => ({
filePath: path.resolve(filePath),
ignored: false
}))
...new Set([
...results,
...globbyResults.map(filePath => path.resolve(filePath))
])
];
}

View file

@ -489,7 +489,7 @@ function verifyText({
* @returns {boolean} `true` if the linter should adopt the code block.
*/
filterCodeBlock(blockFilename) {
return configs.isExplicitMatch(blockFilename);
return configs.getConfig(blockFilename) !== void 0;
}
}
);
@ -541,6 +541,23 @@ function createExtraneousResultsError() {
return new TypeError("Results object was not created from this ESLint instance.");
}
/**
* Creates a fixer function based on the provided fix, fixTypesSet, and config.
* @param {Function|boolean} fix The original fix option.
* @param {Set<string>} fixTypesSet A set of fix types to filter messages for fixing.
* @param {FlatConfig} config The config for the file that generated the message.
* @returns {Function|boolean} The fixer function or the original fix value.
*/
function getFixerForFixTypes(fix, fixTypesSet, config) {
if (!fix || !fixTypesSet) {
return fix;
}
const originalFix = (typeof fix === "function") ? fix : () => true;
return message => shouldMessageBeFixed(message, config, fixTypesSet) && originalFix(message);
}
//-----------------------------------------------------------------------------
// Main API
//-----------------------------------------------------------------------------
@ -790,28 +807,19 @@ class FlatESLint {
*/
const results = await Promise.all(
filePaths.map(({ filePath, ignored }) => {
/*
* If a filename was entered that matches an ignore
* pattern, then notify the user.
*/
if (ignored) {
if (warnIgnored) {
return createIgnoreResult(filePath, cwd);
}
return void 0;
}
filePaths.map(filePath => {
const config = configs.getConfig(filePath);
/*
* Sometimes a file found through a glob pattern will
* be ignored. In this case, `config` will be undefined
* and we just silently ignore the file.
* If a filename was entered that cannot be matched
* to a config, then notify the user.
*/
if (!config) {
if (warnIgnored) {
return createIgnoreResult(filePath, cwd);
}
return void 0;
}
@ -836,16 +844,7 @@ class FlatESLint {
// set up fixer for fixTypes if necessary
let fixer = fix;
if (fix && fixTypesSet) {
// save original value of options.fix in case it's a function
const originalFix = (typeof fix === "function")
? fix : () => true;
fixer = message => shouldMessageBeFixed(message, config, fixTypesSet) && originalFix(message);
}
const fixer = getFixerForFixTypes(fix, fixTypesSet, config);
return fs.readFile(filePath, "utf8")
.then(text => {
@ -942,11 +941,16 @@ class FlatESLint {
allowInlineConfig,
cwd,
fix,
fixTypes,
warnIgnored: constructorWarnIgnored
} = eslintOptions;
const results = [];
const startTime = Date.now();
const fixTypesSet = fixTypes ? new Set(fixTypes) : null;
const resolvedFilename = path.resolve(cwd, filePath || "__placeholder__.js");
const config = configs.getConfig(resolvedFilename);
const fixer = getFixerForFixTypes(fix, fixTypesSet, config);
// Clear the last used config arrays.
if (resolvedFilename && await this.isPathIgnored(resolvedFilename)) {
@ -963,7 +967,7 @@ class FlatESLint {
filePath: resolvedFilename.endsWith("__placeholder__.js") ? "<text>" : resolvedFilename,
configs,
cwd,
fix,
fix: fixer,
allowInlineConfig,
linter
}));

View file

@ -733,7 +733,7 @@ function createLanguageOptions({ globals: configuredGlobals, parser, parserOptio
*/
function resolveGlobals(providedGlobals, enabledEnvironments) {
return Object.assign(
{},
Object.create(null),
...enabledEnvironments.filter(env => env.globals).map(env => env.globals),
providedGlobals
);

View file

@ -934,7 +934,7 @@ class SourceCode extends TokenStore {
* https://github.com/eslint/eslint/issues/16302
*/
const configGlobals = Object.assign(
{},
Object.create(null), // https://github.com/eslint/eslint/issues/18363
getGlobalsForEcmaVersion(languageOptions.ecmaVersion),
languageOptions.sourceType === "commonjs" ? globals.commonjs : void 0,
languageOptions.globals

View file

@ -1,6 +1,6 @@
{
"name": "@eslint/js",
"version": "8.57.0",
"version": "8.57.1",
"description": "ESLint JavaScript language implementation",
"main": "./src/index.js",
"scripts": {},

14
node_modules/eslint/package.json generated vendored
View file

@ -1,6 +1,6 @@
{
"name": "eslint",
"version": "8.57.0",
"version": "8.57.1",
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
"description": "An AST-based pattern checker for JavaScript.",
"bin": {
@ -24,7 +24,8 @@
"lint:fix:docs:js": "node Makefile.js lintDocsJS -- fix",
"release:generate:alpha": "node Makefile.js generatePrerelease -- alpha",
"release:generate:beta": "node Makefile.js generatePrerelease -- beta",
"release:generate:latest": "node Makefile.js generateRelease",
"release:generate:latest": "node Makefile.js generateRelease -- latest",
"release:generate:maintenance": "node Makefile.js generateRelease -- maintenance",
"release:generate:rc": "node Makefile.js generatePrerelease -- rc",
"release:publish": "node Makefile.js publishRelease",
"test": "node Makefile.js test",
@ -65,8 +66,8 @@
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.4",
"@eslint/js": "8.57.0",
"@humanwhocodes/config-array": "^0.11.14",
"@eslint/js": "8.57.1",
"@humanwhocodes/config-array": "^0.13.0",
"@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8",
"@ungap/structured-clone": "^1.2.0",
@ -104,6 +105,7 @@
"devDependencies": {
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@sinonjs/fake-timers": "11.2.2",
"@wdio/browser-runner": "^8.14.6",
"@wdio/cli": "^8.14.6",
"@wdio/concise-reporter": "^8.14.0",
@ -124,7 +126,7 @@
"eslint-plugin-jsdoc": "^46.2.5",
"eslint-plugin-n": "^16.6.0",
"eslint-plugin-unicorn": "^49.0.0",
"eslint-release": "^3.2.0",
"eslint-release": "^3.3.0",
"eslump": "^3.0.0",
"esprima": "^4.0.1",
"fast-glob": "^3.2.11",
@ -159,7 +161,7 @@
"semver": "^7.5.3",
"shelljs": "^0.8.2",
"sinon": "^11.0.0",
"vite-plugin-commonjs": "^0.10.0",
"vite-plugin-commonjs": "0.10.1",
"webdriverio": "^8.14.6",
"webpack": "^5.23.0",
"webpack-cli": "^4.5.0",