Update checked-in dependencies

This commit is contained in:
github-actions[bot]
2021-07-27 16:54:26 +00:00
parent 6b0d45a5c6
commit cc1adb825a
4247 changed files with 144820 additions and 149530 deletions

View File

@@ -1,5 +1,5 @@
'use strict'
exports.__esModule = true
'use strict';
exports.__esModule = true;
/**
* Returns an object of node visitors that will call
@@ -12,95 +12,103 @@ exports.__esModule = true
*/
exports.default = function visitModules(visitor, options) {
// if esmodule is not explicitly disabled, it is assumed to be enabled
options = Object.assign({ esmodule: true }, options)
options = Object.assign({ esmodule: true }, options);
let ignoreRegExps = []
let ignoreRegExps = [];
if (options.ignore != null) {
ignoreRegExps = options.ignore.map(p => new RegExp(p))
ignoreRegExps = options.ignore.map(p => new RegExp(p));
}
function checkSourceValue(source, importer) {
if (source == null) return //?
if (source == null) return; //?
// handle ignore
if (ignoreRegExps.some(re => re.test(source.value))) return
if (ignoreRegExps.some(re => re.test(source.value))) return;
// fire visitor
visitor(source, importer)
visitor(source, importer);
}
// for import-y declarations
function checkSource(node) {
checkSourceValue(node.source, node)
checkSourceValue(node.source, node);
}
// for esmodule dynamic `import()` calls
function checkImportCall(node) {
if (node.callee.type !== 'Import') return
if (node.arguments.length !== 1) return
let modulePath;
// refs https://github.com/estree/estree/blob/master/es2020.md#importexpression
if (node.type === 'ImportExpression') {
modulePath = node.source;
} else if (node.type === 'CallExpression') {
if (node.callee.type !== 'Import') return;
if (node.arguments.length !== 1) return;
const modulePath = node.arguments[0]
if (modulePath.type !== 'Literal') return
if (typeof modulePath.value !== 'string') return
modulePath = node.arguments[0];
}
checkSourceValue(modulePath, node)
if (modulePath.type !== 'Literal') return;
if (typeof modulePath.value !== 'string') return;
checkSourceValue(modulePath, node);
}
// for CommonJS `require` calls
// adapted from @mctep: http://git.io/v4rAu
function checkCommon(call) {
if (call.callee.type !== 'Identifier') return
if (call.callee.name !== 'require') return
if (call.arguments.length !== 1) return
if (call.callee.type !== 'Identifier') return;
if (call.callee.name !== 'require') return;
if (call.arguments.length !== 1) return;
const modulePath = call.arguments[0]
if (modulePath.type !== 'Literal') return
if (typeof modulePath.value !== 'string') return
const modulePath = call.arguments[0];
if (modulePath.type !== 'Literal') return;
if (typeof modulePath.value !== 'string') return;
checkSourceValue(modulePath, call)
checkSourceValue(modulePath, call);
}
function checkAMD(call) {
if (call.callee.type !== 'Identifier') return
if (call.callee.type !== 'Identifier') return;
if (call.callee.name !== 'require' &&
call.callee.name !== 'define') return
if (call.arguments.length !== 2) return
call.callee.name !== 'define') return;
if (call.arguments.length !== 2) return;
const modules = call.arguments[0]
if (modules.type !== 'ArrayExpression') return
const modules = call.arguments[0];
if (modules.type !== 'ArrayExpression') return;
for (let element of modules.elements) {
if (element.type !== 'Literal') continue
if (typeof element.value !== 'string') continue
for (const element of modules.elements) {
if (element.type !== 'Literal') continue;
if (typeof element.value !== 'string') continue;
if (element.value === 'require' ||
element.value === 'exports') continue // magic modules: http://git.io/vByan
element.value === 'exports') continue; // magic modules: http://git.io/vByan
checkSourceValue(element, element)
checkSourceValue(element, element);
}
}
const visitors = {}
const visitors = {};
if (options.esmodule) {
Object.assign(visitors, {
'ImportDeclaration': checkSource,
'ExportNamedDeclaration': checkSource,
'ExportAllDeclaration': checkSource,
'CallExpression': checkImportCall,
})
'ImportExpression': checkImportCall,
});
}
if (options.commonjs || options.amd) {
const currentCallExpression = visitors['CallExpression']
const currentCallExpression = visitors['CallExpression'];
visitors['CallExpression'] = function (call) {
if (currentCallExpression) currentCallExpression(call)
if (options.commonjs) checkCommon(call)
if (options.amd) checkAMD(call)
}
if (currentCallExpression) currentCallExpression(call);
if (options.commonjs) checkCommon(call);
if (options.amd) checkAMD(call);
};
}
return visitors
}
return visitors;
};
/**
* make an options schema for the module visitor, optionally
@@ -121,21 +129,21 @@ function makeOptionsSchema(additionalProperties) {
},
},
'additionalProperties': false,
}
};
if (additionalProperties){
for (let key in additionalProperties) {
base.properties[key] = additionalProperties[key]
for (const key in additionalProperties) {
base.properties[key] = additionalProperties[key];
}
}
return base
return base;
}
exports.makeOptionsSchema = makeOptionsSchema
exports.makeOptionsSchema = makeOptionsSchema;
/**
* json schema object for options parameter. can be used to build
* rule options schema object.
* @type {Object}
*/
exports.optionsSchema = makeOptionsSchema()
exports.optionsSchema = makeOptionsSchema();