Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2024-08-26 17:13:37 +00:00
parent fa428daf9c
commit b3bf514df4
216 changed files with 4342 additions and 1611 deletions

View file

@ -2,50 +2,58 @@
exports.__esModule = true;
/** @typedef {import('estree').Node} Node */
/** @typedef {{ arguments: import('estree').CallExpression['arguments'], callee: Node }} Call */
/** @typedef {import('estree').ImportDeclaration | import('estree').ExportNamedDeclaration | import('estree').ExportAllDeclaration} Declaration */
/**
* Returns an object of node visitors that will call
* 'visitor' with every discovered module path.
*
* todo: correct function prototype for visitor
* @param {Function(String)} visitor [description]
* @param {[type]} options [description]
* @return {object}
* @type {(import('./moduleVisitor').default)}
*/
exports.default = function visitModules(visitor, options) {
const ignore = options && options.ignore;
const amd = !!(options && options.amd);
const commonjs = !!(options && options.commonjs);
// if esmodule is not explicitly disabled, it is assumed to be enabled
options = Object.assign({ esmodule: true }, options);
const esmodule = !!Object.assign({ esmodule: true }, options).esmodule;
let ignoreRegExps = [];
if (options.ignore != null) {
ignoreRegExps = options.ignore.map((p) => new RegExp(p));
}
const ignoreRegExps = ignore == null ? [] : ignore.map((p) => new RegExp(p));
/** @type {(source: undefined | null | import('estree').Literal, importer: Parameters<typeof visitor>[1]) => void} */
function checkSourceValue(source, importer) {
if (source == null) { return; } //?
// handle ignore
if (ignoreRegExps.some((re) => re.test(source.value))) { return; }
if (ignoreRegExps.some((re) => re.test(String(source.value)))) { return; }
// fire visitor
visitor(source, importer);
}
// for import-y declarations
/** @type {(node: Declaration) => void} */
function checkSource(node) {
checkSourceValue(node.source, node);
}
// for esmodule dynamic `import()` calls
/** @type {(node: import('estree').ImportExpression | import('estree').CallExpression) => void} */
function checkImportCall(node) {
/** @type {import('estree').Expression | import('estree').Literal | import('estree').CallExpression['arguments'][0]} */
let modulePath;
// refs https://github.com/estree/estree/blob/HEAD/es2020.md#importexpression
if (node.type === 'ImportExpression') {
modulePath = node.source;
} else if (node.type === 'CallExpression') {
// @ts-expect-error this structure is from an older version of eslint
if (node.callee.type !== 'Import') { return; }
if (node.arguments.length !== 1) { return; }
modulePath = node.arguments[0];
} else {
throw new TypeError('this should be unreachable');
}
if (modulePath.type !== 'Literal') { return; }
@ -56,6 +64,7 @@ exports.default = function visitModules(visitor, options) {
// for CommonJS `require` calls
// adapted from @mctep: https://git.io/v4rAu
/** @type {(call: Call) => void} */
function checkCommon(call) {
if (call.callee.type !== 'Identifier') { return; }
if (call.callee.name !== 'require') { return; }
@ -68,6 +77,7 @@ exports.default = function visitModules(visitor, options) {
checkSourceValue(modulePath, call);
}
/** @type {(call: Call) => void} */
function checkAMD(call) {
if (call.callee.type !== 'Identifier') { return; }
if (call.callee.name !== 'require' && call.callee.name !== 'define') { return; }
@ -77,6 +87,7 @@ exports.default = function visitModules(visitor, options) {
if (modules.type !== 'ArrayExpression') { return; }
for (const element of modules.elements) {
if (!element) { continue; }
if (element.type !== 'Literal') { continue; }
if (typeof element.value !== 'string') { continue; }
@ -92,7 +103,7 @@ exports.default = function visitModules(visitor, options) {
}
const visitors = {};
if (options.esmodule) {
if (esmodule) {
Object.assign(visitors, {
ImportDeclaration: checkSource,
ExportNamedDeclaration: checkSource,
@ -102,12 +113,12 @@ exports.default = function visitModules(visitor, options) {
});
}
if (options.commonjs || options.amd) {
if (commonjs || amd) {
const currentCallExpression = visitors.CallExpression;
visitors.CallExpression = function (call) {
visitors.CallExpression = /** @type {(call: Call) => void} */ function (call) {
if (currentCallExpression) { currentCallExpression(call); }
if (options.commonjs) { checkCommon(call); }
if (options.amd) { checkAMD(call); }
if (commonjs) { checkCommon(call); }
if (amd) { checkAMD(call); }
};
}
@ -115,10 +126,11 @@ exports.default = function visitModules(visitor, options) {
};
/**
* make an options schema for the module visitor, optionally
* adding extra fields.
* make an options schema for the module visitor, optionally adding extra fields.
* @type {import('./moduleVisitor').makeOptionsSchema}
*/
function makeOptionsSchema(additionalProperties) {
/** @type {import('./moduleVisitor').Schema} */
const base = {
type: 'object',
properties: {
@ -137,6 +149,7 @@ function makeOptionsSchema(additionalProperties) {
if (additionalProperties) {
for (const key in additionalProperties) {
// @ts-expect-error TS always has trouble with arbitrary object assignment/mutation
base.properties[key] = additionalProperties[key];
}
}
@ -146,8 +159,6 @@ function makeOptionsSchema(additionalProperties) {
exports.makeOptionsSchema = makeOptionsSchema;
/**
* json schema object for options parameter. can be used to build
* rule options schema object.
* @type {Object}
* json schema object for options parameter. can be used to build rule options schema object.
*/
exports.optionsSchema = makeOptionsSchema();