141 lines
No EOL
16 KiB
JavaScript
141 lines
No EOL
16 KiB
JavaScript
'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _path = require('path');var path = _interopRequireWildcard(_path);
|
|
var _ExportMap = require('../ExportMap');var _ExportMap2 = _interopRequireDefault(_ExportMap);
|
|
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}function _interopRequireWildcard(obj) {if (obj && obj.__esModule) {return obj;} else {var newObj = {};if (obj != null) {for (var key in obj) {if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];}}newObj['default'] = obj;return newObj;}}
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'problem',
|
|
docs: {
|
|
url: (0, _docsUrl2['default'])('named') },
|
|
|
|
schema: [
|
|
{
|
|
type: 'object',
|
|
properties: {
|
|
commonjs: {
|
|
type: 'boolean' } },
|
|
|
|
|
|
additionalProperties: false }] },
|
|
|
|
|
|
|
|
|
|
create: function () {function create(context) {
|
|
var options = context.options[0] || {};
|
|
|
|
function checkSpecifiers(key, type, node) {
|
|
// ignore local exports and type imports/exports
|
|
if (
|
|
node.source == null ||
|
|
node.importKind === 'type' ||
|
|
node.importKind === 'typeof' ||
|
|
node.exportKind === 'type')
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!node.specifiers.some(function (im) {return im.type === type;})) {
|
|
return; // no named imports/exports
|
|
}
|
|
|
|
var imports = _ExportMap2['default'].get(node.source.value, context);
|
|
if (imports == null || imports.parseGoal === 'ambiguous') {
|
|
return;
|
|
}
|
|
|
|
if (imports.errors.length) {
|
|
imports.reportErrors(context, node);
|
|
return;
|
|
}
|
|
|
|
node.specifiers.forEach(function (im) {
|
|
if (
|
|
im.type !== type
|
|
// ignore type imports
|
|
|| im.importKind === 'type' || im.importKind === 'typeof')
|
|
{
|
|
return;
|
|
}
|
|
|
|
var name = im[key].name || im[key].value;
|
|
|
|
var deepLookup = imports.hasDeep(name);
|
|
|
|
if (!deepLookup.found) {
|
|
if (deepLookup.path.length > 1) {
|
|
var deepPath = deepLookup.path.
|
|
map(function (i) {return path.relative(path.dirname(context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename()), i.path);}).
|
|
join(' -> ');
|
|
|
|
context.report(im[key], String(name) + ' not found via ' + String(deepPath));
|
|
} else {
|
|
context.report(im[key], name + ' not found in \'' + node.source.value + '\'');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function checkRequire(node) {
|
|
if (
|
|
!options.commonjs ||
|
|
node.type !== 'VariableDeclarator'
|
|
// return if it's not an object destructure or it's an empty object destructure
|
|
|| !node.id || node.id.type !== 'ObjectPattern' || node.id.properties.length === 0
|
|
// return if there is no call expression on the right side
|
|
|| !node.init || node.init.type !== 'CallExpression')
|
|
{
|
|
return;
|
|
}
|
|
|
|
var call = node.init;var _call$arguments = _slicedToArray(
|
|
call.arguments, 1),source = _call$arguments[0];
|
|
var variableImports = node.id.properties;
|
|
var variableExports = _ExportMap2['default'].get(source.value, context);
|
|
|
|
if (
|
|
// return if it's not a commonjs require statement
|
|
call.callee.type !== 'Identifier' || call.callee.name !== 'require' || call.arguments.length !== 1
|
|
// return if it's not a string source
|
|
|| source.type !== 'Literal' ||
|
|
variableExports == null ||
|
|
variableExports.parseGoal === 'ambiguous')
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (variableExports.errors.length) {
|
|
variableExports.reportErrors(context, node);
|
|
return;
|
|
}
|
|
|
|
variableImports.forEach(function (im) {
|
|
if (im.type !== 'Property' || !im.key || im.key.type !== 'Identifier') {
|
|
return;
|
|
}
|
|
|
|
var deepLookup = variableExports.hasDeep(im.key.name);
|
|
|
|
if (!deepLookup.found) {
|
|
if (deepLookup.path.length > 1) {
|
|
var deepPath = deepLookup.path.
|
|
map(function (i) {return path.relative(path.dirname(context.getFilename()), i.path);}).
|
|
join(' -> ');
|
|
|
|
context.report(im.key, String(im.key.name) + ' not found via ' + String(deepPath));
|
|
} else {
|
|
context.report(im.key, im.key.name + ' not found in \'' + source.value + '\'');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
return {
|
|
ImportDeclaration: checkSpecifiers.bind(null, 'imported', 'ImportSpecifier'),
|
|
|
|
ExportNamedDeclaration: checkSpecifiers.bind(null, 'local', 'ExportSpecifier'),
|
|
|
|
VariableDeclarator: checkRequire };
|
|
|
|
}return create;}() };
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uYW1lZC5qcyJdLCJuYW1lcyI6WyJwYXRoIiwibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsInByb3BlcnRpZXMiLCJjb21tb25qcyIsImFkZGl0aW9uYWxQcm9wZXJ0aWVzIiwiY3JlYXRlIiwiY29udGV4dCIsIm9wdGlvbnMiLCJjaGVja1NwZWNpZmllcnMiLCJrZXkiLCJub2RlIiwic291cmNlIiwiaW1wb3J0S2luZCIsImV4cG9ydEtpbmQiLCJzcGVjaWZpZXJzIiwic29tZSIsImltIiwiaW1wb3J0cyIsIkV4cG9ydHMiLCJnZXQiLCJ2YWx1ZSIsInBhcnNlR29hbCIsImVycm9ycyIsImxlbmd0aCIsInJlcG9ydEVycm9ycyIsImZvckVhY2giLCJuYW1lIiwiZGVlcExvb2t1cCIsImhhc0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zVXJsJztcblxubW9kdWxlLmV4cG9ydHMgPSB7XG4gIG1ldGE6IHtcbiAgICB0eXBlOiAncHJvYmxlbScsXG4gICAgZG9jczoge1xuICAgICAgdXJsOiBkb2NzVXJsKCduYW1lZCcpLFxuICAgIH0sXG4gICAgc2NoZW1hOiBbXG4gICAgICB7XG4gICAgICAgIHR5cGU6ICdvYmplY3QnLFxuICAgICAgICBwcm9wZXJ0aWVzOiB7XG4gICAgICAgICAgY29tbW9uanM6IHtcbiAgICAgICAgICAgIHR5cGU6ICdib29sZWFuJyxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgICBhZGRpdGlvbmFsUHJvcGVydGllczogZmFsc2UsXG4gICAgICB9LFxuICAgIF0sXG4gIH0sXG5cbiAgY3JlYXRlKGNvbnRleHQpIHtcbiAgICBjb25zdCBvcHRpb25zID0gY29udGV4dC5vcHRpb25zWzBdIHx8IHt9O1xuXG4gICAgZnVuY3Rpb24gY2hlY2tTcGVjaWZpZXJzKGtleSwgdHlwZSwgbm9kZSkge1xuICAgICAgLy8gaWdub3JlIGxvY2FsIGV4cG9ydHMgYW5kIHR5cGUgaW1wb3J0cy9leHBvcnRzXG4gICAgICBpZiAoXG4gICAgICAgIG5vZGUuc291cmNlID09IG51bGxcbiAgICAgICAgfHwgbm9kZS5pbXBvcnRLaW5kID09PSAndHlwZSdcbiAgICAgICAgfHwgbm9kZS5pbXBvcnRLaW5kID09PSAndHlwZW9mJ1xuICAgICAgICB8fCBub2RlLmV4cG9ydEtpbmQgPT09ICd0eXBlJ1xuICAgICAgKSB7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgaWYgKCFub2RlLnNwZWNpZmllcnMuc29tZSgoaW0pID0+IGltLnR5cGUgPT09IHR5cGUpKSB7XG4gICAgICAgIHJldHVybjsgLy8gbm8gbmFtZWQgaW1wb3J0cy9leHBvcnRzXG4gICAgICB9XG5cbiAgICAgIGNvbnN0IGltcG9ydHMgPSBFeHBvcnRzLmdldChub2RlLnNvdXJjZS52YWx1ZSwgY29udGV4dCk7XG4gICAgICBpZiAoaW1wb3J0cyA9PSBudWxsIHx8IGltcG9ydHMucGFyc2VHb2FsID09PSAnYW1iaWd1b3VzJykge1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIGlmIChpbXBvcnRzLmVycm9ycy5sZW5ndGgpIHtcbiAgICAgICAgaW1wb3J0cy5yZXBvcnRFcnJvcnMoY29udGV4dCwgbm9kZSk7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgbm9kZS5zcGVjaWZpZXJzLmZvckVhY2goZnVuY3Rpb24gKGltKSB7XG4gICAgICAgIGlmIChcbiAgICAgICAgICBpbS50eXBlICE9PSB0eXBlXG4gICAgICAgICAgLy8gaWdub3JlIHR5cGUgaW1wb3J0c1xuICAgICAgICAgIHx8IGltLmltcG9ydEtpbmQgPT09ICd0eXBlJyB8fCBpbS5pbXBvcnRLaW5kID09PSAndHlwZW9mJ1xuICAgICAgICApIHtcbiAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCBuYW1lID0gaW1ba2V5XS5uYW1lIHx8IGltW2tleV0udmFsdWU7XG5cbiAgICAgICAgY29uc3QgZGVlcExvb2t1cCA9IGltcG9ydHMuaGFzRGVlcChuYW1lKTtcblxuICAgICAgICBpZiAoIWRlZXBMb29rdXAuZm91bmQpIHtcbiAgICAgICAgICBpZiAoZGVlcExvb2t1cC5wYXRoLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgIGNvbnN0IGRlZXBQYXRoID0gZGVlcExvb2t1cC5wYXRoXG4gICAgICAgICAgICAgIC5tYXAoaSA9PiBwYXRoLnJlbGF0aXZlKHBhdGguZGlybmFtZShjb250ZXh0LmdldFBoeXNpY2FsRmlsZW5hbWUgPyBjb250ZXh0LmdldFBoeXNpY2FsRmlsZW5hbWUoKSA6IGNvbnRleHQuZ2V0RmlsZW5hbWUoKSksIGkucGF0a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tZSk7XG5cbiAgICAgICAgaWYgKCFkZWVwTG9va3VwLmZvdW5kKSB7XG4gICAgICAgICAgaWYgKGRlZXBMb29rdXAucGF0aC5sZW5ndGggPiAxKSB7XG4gICAgICAgICAgICBjb25zdCBkZWVwUGF0aCA9IGRlZXBMb29rdXAucGF0aFxuICAgICAgICAgICAgICAubWFwKGkgPT4gcGF0aC5yZWxhdGl2ZShwYXRoLmRpcm5hbWUoY29udGV4dC5nZXRGaWxlbmFtZSgpKSwgaS5wYXRoKSlcbiAgICAgICAgICAgICAgLmpvaW4oJyAtPiAnKTtcblxuICAgICAgICAgICAgY29udGV4dC5yZXBvcnQoaW0ua2V5LCBgJHtpbS5rZXkubmFtZX0gbm90IGZvdW5kIHZpYSAke2RlZXBQYXRofWApO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb250ZXh0LnJlcG9ydChpbS5rZXksIGltLmtleS5uYW1lICsgJyBub3QgZm91bmQgaW4gXFwnJyArIHNvdXJjZS52YWx1ZSArICdcXCcnKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cblxuICAgIHJldHVybiB7XG4gICAgICBJbXBvcnREZWNsYXJhdGlvbjogY2hlY2tTcGVjaWZpZXJzLmJpbmQobnVsbCwgJ2ltcG9ydGVkJywgJ0ltcG9ydFNwZWNpZmllcicpLFxuXG4gICAgICBFeHBvcnROYW1lZERlY2xhcmF0aW9uOiBjaGVja1NwZWNpZmllcnMuYmluZChudWxsLCAnbG9jYWwnLCAnRXhwb3J0U3BlY2lmaWVyJyksXG5cbiAgICAgIFZhcmlhYmxlRGVjbGFyYXRvcjogY2hlY2tSZXF1aXJlLFxuICAgIH07XG4gIH0sXG59O1xuIl19
|