Update checked-in dependencies
This commit is contained in:
parent
1afca056e3
commit
6989ba7bd2
3942 changed files with 55190 additions and 132206 deletions
130
node_modules/@humanwhocodes/config-array/api.js
generated
vendored
130
node_modules/@humanwhocodes/config-array/api.js
generated
vendored
|
|
@ -154,8 +154,82 @@ const MINIMATCH_OPTIONS = {
|
|||
|
||||
const CONFIG_TYPES = new Set(['array', 'function']);
|
||||
|
||||
/**
|
||||
* Fields that are considered metadata and not part of the config object.
|
||||
*/
|
||||
const META_FIELDS = new Set(['name']);
|
||||
|
||||
const FILES_AND_IGNORES_SCHEMA = new objectSchema.ObjectSchema(filesAndIgnoresSchema);
|
||||
|
||||
/**
|
||||
* Wrapper error for config validation errors that adds a name to the front of the
|
||||
* error message.
|
||||
*/
|
||||
class ConfigError extends Error {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} name The config object name causing the error.
|
||||
* @param {number} index The index of the config object in the array.
|
||||
* @param {Error} source The source error.
|
||||
*/
|
||||
constructor(name, index, { cause, message }) {
|
||||
|
||||
|
||||
const finalMessage = message || cause.message;
|
||||
|
||||
super(`Config ${name}: ${finalMessage}`, { cause });
|
||||
|
||||
// copy over custom properties that aren't represented
|
||||
if (cause) {
|
||||
for (const key of Object.keys(cause)) {
|
||||
if (!(key in this)) {
|
||||
this[key] = cause[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the error.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
this.name = 'ConfigError';
|
||||
|
||||
/**
|
||||
* The index of the config object in the array.
|
||||
* @type {number}
|
||||
* @readonly
|
||||
*/
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of a config object.
|
||||
* @param {object} config The config object to get the name of.
|
||||
* @returns {string} The name of the config object.
|
||||
*/
|
||||
function getConfigName(config) {
|
||||
if (config && typeof config.name === 'string' && config.name) {
|
||||
return `"${config.name}"`;
|
||||
}
|
||||
|
||||
return '(unnamed)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Rethrows a config error with additional information about the config object.
|
||||
* @param {object} config The config object to get the name of.
|
||||
* @param {number} index The index of the config object in the array.
|
||||
* @param {Error} error The error to rethrow.
|
||||
* @throws {ConfigError} When the error is rethrown for a config.
|
||||
*/
|
||||
function rethrowConfigError(config, index, error) {
|
||||
const configName = getConfigName(config);
|
||||
throw new ConfigError(configName, index, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand for checking if a value is a string.
|
||||
* @param {any} value The value to check.
|
||||
|
|
@ -166,23 +240,43 @@ function isString(value) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Asserts that the files and ignores keys of a config object are valid as per base schema.
|
||||
* @param {object} config The config object to check.
|
||||
* Creates a function that asserts that the config is valid
|
||||
* during normalization. This checks that the config is not nullish
|
||||
* and that files and ignores keys of a config object are valid as per base schema.
|
||||
* @param {Object} config The config object to check.
|
||||
* @param {number} index The index of the config object in the array.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the files and ignores keys of a config object are not valid.
|
||||
* @throws {ConfigError} If the files and ignores keys of a config object are not valid.
|
||||
*/
|
||||
function assertValidFilesAndIgnores(config) {
|
||||
if (!config || typeof config !== 'object') {
|
||||
return;
|
||||
function assertValidBaseConfig(config, index) {
|
||||
|
||||
if (config === null) {
|
||||
throw new ConfigError(getConfigName(config), index, { message: 'Unexpected null config.' });
|
||||
}
|
||||
|
||||
if (config === undefined) {
|
||||
throw new ConfigError(getConfigName(config), index, { message: 'Unexpected undefined config.' });
|
||||
}
|
||||
|
||||
if (typeof config !== 'object') {
|
||||
throw new ConfigError(getConfigName(config), index, { message: 'Unexpected non-object config.' });
|
||||
}
|
||||
|
||||
const validateConfig = { };
|
||||
|
||||
if ('files' in config) {
|
||||
validateConfig.files = config.files;
|
||||
}
|
||||
|
||||
if ('ignores' in config) {
|
||||
validateConfig.ignores = config.ignores;
|
||||
}
|
||||
FILES_AND_IGNORES_SCHEMA.validate(validateConfig);
|
||||
|
||||
try {
|
||||
FILES_AND_IGNORES_SCHEMA.validate(validateConfig);
|
||||
} catch (validationError) {
|
||||
rethrowConfigError(config, index, { cause: validationError });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -377,7 +471,7 @@ function pathMatchesIgnores(filePath, basePath, config) {
|
|||
*/
|
||||
const relativeFilePath = path.relative(basePath, filePath);
|
||||
|
||||
return Object.keys(config).length > 1 &&
|
||||
return Object.keys(config).filter(key => !META_FIELDS.has(key)).length > 1 &&
|
||||
!shouldIgnorePath(config.ignores, filePath, relativeFilePath);
|
||||
}
|
||||
|
||||
|
|
@ -511,7 +605,7 @@ class ConfigArray extends Array {
|
|||
/**
|
||||
* Tracks if the array has been normalized.
|
||||
* @property isNormalized
|
||||
* @type boolean
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this[ConfigArraySymbol.isNormalized] = normalized;
|
||||
|
|
@ -530,7 +624,7 @@ class ConfigArray extends Array {
|
|||
* The path of the config file that this array was loaded from.
|
||||
* This is used to calculate filename matches.
|
||||
* @property basePath
|
||||
* @type string
|
||||
* @type {string}
|
||||
*/
|
||||
this.basePath = basePath;
|
||||
|
||||
|
|
@ -539,14 +633,14 @@ class ConfigArray extends Array {
|
|||
/**
|
||||
* The supported config types.
|
||||
* @property configTypes
|
||||
* @type Array<string>
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
this.extraConfigTypes = Object.freeze([...extraConfigTypes]);
|
||||
|
||||
/**
|
||||
* A cache to store calculated configs for faster repeat lookup.
|
||||
* @property configCache
|
||||
* @type Map
|
||||
* @type {Map<string, Object>}
|
||||
* @private
|
||||
*/
|
||||
this[ConfigArraySymbol.configCache] = new Map();
|
||||
|
|
@ -645,7 +739,7 @@ class ConfigArray extends Array {
|
|||
* In this case, it acts list a globally ignored pattern. If there
|
||||
* are additional keys, then ignores act like exclusions.
|
||||
*/
|
||||
if (config.ignores && Object.keys(config).length === 1) {
|
||||
if (config.ignores && Object.keys(config).filter(key => !META_FIELDS.has(key)).length === 1) {
|
||||
result.push(...config.ignores);
|
||||
}
|
||||
}
|
||||
|
|
@ -677,7 +771,7 @@ class ConfigArray extends Array {
|
|||
const normalizedConfigs = await normalize(this, context, this.extraConfigTypes);
|
||||
this.length = 0;
|
||||
this.push(...normalizedConfigs.map(this[ConfigArraySymbol.preprocessConfig].bind(this)));
|
||||
this.forEach(assertValidFilesAndIgnores);
|
||||
this.forEach(assertValidBaseConfig);
|
||||
this[ConfigArraySymbol.isNormalized] = true;
|
||||
|
||||
// prevent further changes
|
||||
|
|
@ -699,7 +793,7 @@ class ConfigArray extends Array {
|
|||
const normalizedConfigs = normalizeSync(this, context, this.extraConfigTypes);
|
||||
this.length = 0;
|
||||
this.push(...normalizedConfigs.map(this[ConfigArraySymbol.preprocessConfig].bind(this)));
|
||||
this.forEach(assertValidFilesAndIgnores);
|
||||
this.forEach(assertValidBaseConfig);
|
||||
this[ConfigArraySymbol.isNormalized] = true;
|
||||
|
||||
// prevent further changes
|
||||
|
|
@ -932,7 +1026,11 @@ class ConfigArray extends Array {
|
|||
// otherwise construct the config
|
||||
|
||||
finalConfig = matchingConfigIndices.reduce((result, index) => {
|
||||
return this[ConfigArraySymbol.schema].merge(result, this[index]);
|
||||
try {
|
||||
return this[ConfigArraySymbol.schema].merge(result, this[index]);
|
||||
} catch (validationError) {
|
||||
rethrowConfigError(this[index], index, { cause: validationError});
|
||||
}
|
||||
}, {}, this);
|
||||
|
||||
finalConfig = this[ConfigArraySymbol.finalizeConfig](finalConfig);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue