mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
138 lines
16 KiB
JavaScript
138 lines
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) {
|
|
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 deepLookup = imports.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.getPhysicalFilename ? context.getPhysicalFilename() : 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 \'' + 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)
|
|
{
|
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uYW1lZC5qcyJdLCJuYW1lcyI6WyJwYXRoIiwibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsInByb3BlcnRpZXMiLCJjb21tb25qcyIsImFkZGl0aW9uYWxQcm9wZXJ0aWVzIiwiY3JlYXRlIiwiY29udGV4dCIsIm9wdGlvbnMiLCJjaGVja1NwZWNpZmllcnMiLCJrZXkiLCJub2RlIiwic291cmNlIiwiaW1wb3J0S2luZCIsImV4cG9ydEtpbmQiLCJzcGVjaWZpZXJzIiwic29tZSIsImltIiwiaW1wb3J0cyIsIkV4cG9ydHMiLCJnZXQiLCJ2YWx1ZSIsImVycm9ycyIsImxlbmd0aCIsInJlcG9ydEVycm9ycyIsImZvckVhY2giLCJkZWVwTG9va3VwIiwiaGFzRGVlcCIsIm5hbWUiLCJmb3VuZCIsImRlZXBQYXRoIi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4gICAgICB9XG5cbiAgICAgIGlmIChpbXBvcnRzLmVycm9ycy5sZW5ndGgpIHtcbiAgICAgICAgaW1wb3J0cy5yZXBvcnRFcnJvcnMoY29udGV4dCwgbm9kZSk7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgbm9kZS5zcGVjaWZpZXJzLmZvckVhY2goZnVuY3Rpb24gKGltKSB7XG4gICAgICAgIGlmIChcbiAgICAgICAgICBpbS50eXBlICE9PSB0eXBlXG4gICAgICAgICAgLy8gaWdub3JlIHR5cGUgaW1wb3J0c1xuICAgICAgICAgIHx8IGltLmltcG9ydEtpbmQgPT09ICd0eXBlJyB8fCBpbS5pbXBvcnRLaW5kID09PSAndHlwZW9mJ1xuICAgICAgICApIHtcbiAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCBkZWVwTG9va3VwID0gaW1wb3J0cy5oYXNEZWVwKGltW2tleV0ubmFtZSk7XG5cbiAgICAgICAgaWYgKCFkZWVwTG9va3VwLmZvdW5kKSB7XG4gICAgICAgICAgaWYgKGRlZXBMb29rdXAucGF0aC5sZW5ndGggPiAxKSB7XG4gICAgICAgICAgICBjb25zdCBkZWVwUGF0aCA9IGRlZXBMb29rdXAucGF0aFxuICAgICAgICAgICAgICAubWFwKGkgPT4gcGF0aC5yZWxhdGl2ZShwYXRoLmRpcm5hbWUoY29udGV4dC5nZXRQaHlzaWNhbEZpbGVuYW1lID8gY29udGV4dC5nZXRQaHlzaWNhbEZpbGVuYW1lKCkgOiBjb250ZXh0LmdldEZpbGVuYW1lKCkpLCBpLnBhdGgpKVxuICAgICAgICAgICAgICAuam9pbignIC0+ICcpO1xuXG4gICAgICAgICAgICBjb250ZXh0LnJlcG9ydChpbVtrZXldLCBgJHtpbVtrZXldLm5hbWV9IG5vdCBmb3VuZCB2aWEgJHtkZWVwUGF0aH1gKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29udGV4dC5yZXBvcnQo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