Bump packages to fix linter

This commit is contained in:
Henry Mercer 2023-01-18 20:50:03 +00:00
parent ed9506bbaf
commit 0a11e3fdd9
6063 changed files with 378752 additions and 306784 deletions

View file

@ -33,26 +33,31 @@
*
* @author Toru Nagashima <https://github.com/mysticatea>
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const fs = require("fs");
const path = require("path");
const importFresh = require("import-fresh");
const stripComments = require("strip-json-comments");
const ConfigValidator = require("./shared/config-validator");
const naming = require("./shared/naming");
const ModuleResolver = require("./shared/relative-module-resolver");
const {
import debugOrig from "debug";
import fs from "fs";
import importFresh from "import-fresh";
import { createRequire } from "module";
import path from "path";
import stripComments from "strip-json-comments";
import {
ConfigArray,
ConfigDependency,
IgnorePattern,
OverrideTester
} = require("./config-array");
const debug = require("debug")("eslintrc:config-array-factory");
} from "./config-array/index.js";
import ConfigValidator from "./shared/config-validator.js";
import * as naming from "./shared/naming.js";
import * as ModuleResolver from "./shared/relative-module-resolver.js";
const require = createRequire(import.meta.url);
const debug = debugOrig("eslintrc:config-array-factory");
//------------------------------------------------------------------------------
// Helpers
@ -86,7 +91,9 @@ const configFilenames = [
* @property {Map<string,Rule>} builtInRules The rules that are built in to ESLint.
* @property {Object} [resolver=ModuleResolver] The module resolver object.
* @property {string} eslintAllPath The path to the definitions for eslint:all.
* @property {Function} getEslintAllConfig Returns the config data for eslint:all.
* @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
* @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended.
*/
/**
@ -97,7 +104,9 @@ const configFilenames = [
* @property {Map<string,Rule>} builtInRules The rules that are built in to ESLint.
* @property {Object} [resolver=ModuleResolver] The module resolver object.
* @property {string} eslintAllPath The path to the definitions for eslint:all.
* @property {Function} getEslintAllConfig Returns the config data for eslint:all.
* @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
* @property {Function} getEslintRecommendedConfig Returns the config data for eslint:recommended.
*/
/**
@ -120,6 +129,9 @@ const configFilenames = [
/** @type {WeakMap<ConfigArrayFactory, ConfigArrayFactoryInternalSlots>} */
const internalSlotsMap = new WeakMap();
/** @type {WeakMap<object, Plugin>} */
const normalizedPlugins = new WeakMap();
/**
* Check if a given string is a file path.
* @param {string} nameOrPath A module name or file path.
@ -158,7 +170,7 @@ function loadYAMLConfigFile(filePath) {
try {
// empty YAML file can be null, so always use
return yaml.safeLoad(readFile(filePath)) || {};
return yaml.load(readFile(filePath)) || {};
} catch (e) {
debug(`Error reading YAML file: ${filePath}`);
e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
@ -204,7 +216,7 @@ function loadLegacyConfigFile(filePath) {
const yaml = require("js-yaml");
try {
return yaml.safeLoad(stripComments(readFile(filePath))) || /* istanbul ignore next */ {};
return yaml.load(stripComments(readFile(filePath))) || /* istanbul ignore next */ {};
} catch (e) {
debug("Error reading YAML file: %s\n%o", filePath, e);
e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
@ -396,12 +408,25 @@ function createContext(
* @returns {Plugin} The normalized plugin.
*/
function normalizePlugin(plugin) {
return {
// first check the cache
let normalizedPlugin = normalizedPlugins.get(plugin);
if (normalizedPlugin) {
return normalizedPlugin;
}
normalizedPlugin = {
configs: plugin.configs || {},
environments: plugin.environments || {},
processors: plugin.processors || {},
rules: plugin.rules || {}
};
// save the reference for later
normalizedPlugins.set(plugin, normalizedPlugin);
return normalizedPlugin;
}
//------------------------------------------------------------------------------
@ -424,7 +449,9 @@ class ConfigArrayFactory {
builtInRules,
resolver = ModuleResolver,
eslintAllPath,
eslintRecommendedPath
getEslintAllConfig,
eslintRecommendedPath,
getEslintRecommendedConfig
} = {}) {
internalSlotsMap.set(this, {
additionalPluginPool,
@ -435,7 +462,9 @@ class ConfigArrayFactory {
builtInRules,
resolver,
eslintAllPath,
eslintRecommendedPath
getEslintAllConfig,
eslintRecommendedPath,
getEslintRecommendedConfig
});
}
@ -793,20 +822,41 @@ class ConfigArrayFactory {
* @private
*/
_loadExtendedBuiltInConfig(extendName, ctx) {
const { eslintAllPath, eslintRecommendedPath } = internalSlotsMap.get(this);
const {
eslintAllPath,
getEslintAllConfig,
eslintRecommendedPath,
getEslintRecommendedConfig
} = internalSlotsMap.get(this);
if (extendName === "eslint:recommended") {
const name = `${ctx.name} » ${extendName}`;
if (getEslintRecommendedConfig) {
if (typeof getEslintRecommendedConfig !== "function") {
throw new Error(`getEslintRecommendedConfig must be a function instead of '${getEslintRecommendedConfig}'`);
}
return this._normalizeConfigData(getEslintRecommendedConfig(), { ...ctx, name, filePath: "" });
}
return this._loadConfigData({
...ctx,
filePath: eslintRecommendedPath,
name: `${ctx.name} » ${extendName}`
name,
filePath: eslintRecommendedPath
});
}
if (extendName === "eslint:all") {
const name = `${ctx.name} » ${extendName}`;
if (getEslintAllConfig) {
if (typeof getEslintAllConfig !== "function") {
throw new Error(`getEslintAllConfig must be a function instead of '${getEslintAllConfig}'`);
}
return this._normalizeConfigData(getEslintAllConfig(), { ...ctx, name, filePath: "" });
}
return this._loadConfigData({
...ctx,
filePath: eslintAllPath,
name: `${ctx.name} » ${extendName}`
name,
filePath: eslintAllPath
});
}
@ -922,11 +972,11 @@ class ConfigArrayFactory {
_loadParser(nameOrPath, ctx) {
debug("Loading parser %j from %s", nameOrPath, ctx.filePath);
const { cwd } = internalSlotsMap.get(this);
const { cwd, resolver } = internalSlotsMap.get(this);
const relativeTo = ctx.filePath || path.join(cwd, "__placeholder__.js");
try {
const filePath = ModuleResolver.resolve(nameOrPath, relativeTo);
const filePath = resolver.resolve(nameOrPath, relativeTo);
writeDebugLogForLoading(nameOrPath, relativeTo, filePath);
@ -973,7 +1023,7 @@ class ConfigArrayFactory {
_loadPlugin(name, ctx) {
debug("Loading plugin %j from %s", name, ctx.filePath);
const { additionalPluginPool } = internalSlotsMap.get(this);
const { additionalPluginPool, resolver } = internalSlotsMap.get(this);
const request = naming.normalizePackageName(name, "eslint-plugin");
const id = naming.getShorthandName(request, "eslint-plugin");
const relativeTo = path.join(ctx.pluginBasePath, "__placeholder__.js");
@ -1014,7 +1064,7 @@ class ConfigArrayFactory {
let error;
try {
filePath = ModuleResolver.resolve(request, relativeTo);
filePath = resolver.resolve(request, relativeTo);
} catch (resolveError) {
error = resolveError;
/* istanbul ignore else */
@ -1096,4 +1146,4 @@ class ConfigArrayFactory {
}
}
module.exports = { ConfigArrayFactory, createContext };
export { ConfigArrayFactory, createContext };