named.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. '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);
  2. var _ExportMap = require('../ExportMap');var _ExportMap2 = _interopRequireDefault(_ExportMap);
  3. 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;}}
  4. module.exports = {
  5. meta: {
  6. type: 'problem',
  7. docs: {
  8. url: (0, _docsUrl2['default'])('named') },
  9. schema: [
  10. {
  11. type: 'object',
  12. properties: {
  13. commonjs: {
  14. type: 'boolean' } },
  15. additionalProperties: false }] },
  16. create: function () {function create(context) {
  17. var options = context.options[0] || {};
  18. function checkSpecifiers(key, type, node) {
  19. // ignore local exports and type imports/exports
  20. if (
  21. node.source == null ||
  22. node.importKind === 'type' ||
  23. node.importKind === 'typeof' ||
  24. node.exportKind === 'type')
  25. {
  26. return;
  27. }
  28. if (!node.specifiers.some(function (im) {return im.type === type;})) {
  29. return; // no named imports/exports
  30. }
  31. var imports = _ExportMap2['default'].get(node.source.value, context);
  32. if (imports == null || imports.parseGoal === 'ambiguous') {
  33. return;
  34. }
  35. if (imports.errors.length) {
  36. imports.reportErrors(context, node);
  37. return;
  38. }
  39. node.specifiers.forEach(function (im) {
  40. if (
  41. im.type !== type
  42. // ignore type imports
  43. || im.importKind === 'type' || im.importKind === 'typeof')
  44. {
  45. return;
  46. }
  47. var name = im[key].name || im[key].value;
  48. var deepLookup = imports.hasDeep(name);
  49. if (!deepLookup.found) {
  50. if (deepLookup.path.length > 1) {
  51. var deepPath = deepLookup.path.
  52. map(function (i) {return path.relative(path.dirname(context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename()), i.path);}).
  53. join(' -> ');
  54. context.report(im[key], String(name) + ' not found via ' + String(deepPath));
  55. } else {
  56. context.report(im[key], name + ' not found in \'' + node.source.value + '\'');
  57. }
  58. }
  59. });
  60. }
  61. function checkRequire(node) {
  62. if (
  63. !options.commonjs ||
  64. node.type !== 'VariableDeclarator'
  65. // return if it's not an object destructure or it's an empty object destructure
  66. || !node.id || node.id.type !== 'ObjectPattern' || node.id.properties.length === 0
  67. // return if there is no call expression on the right side
  68. || !node.init || node.init.type !== 'CallExpression')
  69. {
  70. return;
  71. }
  72. var call = node.init;var _call$arguments = _slicedToArray(
  73. call.arguments, 1),source = _call$arguments[0];
  74. var variableImports = node.id.properties;
  75. var variableExports = _ExportMap2['default'].get(source.value, context);
  76. if (
  77. // return if it's not a commonjs require statement
  78. call.callee.type !== 'Identifier' || call.callee.name !== 'require' || call.arguments.length !== 1
  79. // return if it's not a string source
  80. || source.type !== 'Literal' ||
  81. variableExports == null ||
  82. variableExports.parseGoal === 'ambiguous')
  83. {
  84. return;
  85. }
  86. if (variableExports.errors.length) {
  87. variableExports.reportErrors(context, node);
  88. return;
  89. }
  90. variableImports.forEach(function (im) {
  91. if (im.type !== 'Property' || !im.key || im.key.type !== 'Identifier') {
  92. return;
  93. }
  94. var deepLookup = variableExports.hasDeep(im.key.name);
  95. if (!deepLookup.found) {
  96. if (deepLookup.path.length > 1) {
  97. var deepPath = deepLookup.path.
  98. map(function (i) {return path.relative(path.dirname(context.getFilename()), i.path);}).
  99. join(' -> ');
  100. context.report(im.key, String(im.key.name) + ' not found via ' + String(deepPath));
  101. } else {
  102. context.report(im.key, im.key.name + ' not found in \'' + source.value + '\'');
  103. }
  104. }
  105. });
  106. }
  107. return {
  108. ImportDeclaration: checkSpecifiers.bind(null, 'imported', 'ImportSpecifier'),
  109. ExportNamedDeclaration: checkSpecifiers.bind(null, 'local', 'ExportSpecifier'),
  110. VariableDeclarator: checkRequire };
  111. }return create;}() };
  112. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uYW1lZC5qcyJdLCJuYW1lcyI6WyJwYXRoIiwibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsInByb3BlcnRpZXMiLCJjb21tb25qcyIsImFkZGl0aW9uYWxQcm9wZXJ0aWVzIiwiY3JlYXRlIiwiY29udGV4dCIsIm9wdGlvbnMiLCJjaGVja1NwZWNpZmllcnMiLCJrZXkiLCJub2RlIiwic291cmNlIiwiaW1wb3J0S2luZCIsImV4cG9ydEtpbmQiLCJzcGVjaWZpZXJzIiwic29tZSIsImltIiwiaW1wb3J0cyIsIkV4cG9ydHMiLCJnZXQiLCJ2YWx1ZSIsInBhcnNlR29hbCIsImVycm9ycyIsImxlbmd0aCIsInJlcG9ydEVycm9ycyIsImZvckVhY2giLCJuYW1lIiwiZGVlcExvb2t1cCIsImhhc0RlZXAiLCJmb3VuZCIsImRlZXBQYXRoIiwibWFwIiwicmVsYXRpdmUiLCJkaXJuYW1lIiwiZ2V0UGh5c2ljYWxGaWxlbmFtZSIsImdldEZpbGVuYW1lIiwiaSIsImpvaW4iLCJyZXBvcnQiLCJjaGVja1JlcXVpcmUi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G4gICAgICB7XG4gICAgICAgIHR5cGU6ICdvYmplY3QnLFxuICAgICAgICBwcm9wZXJ0aWVzOiB7XG4gICAgICAgICAgY29tbW9uanM6IHtcbiAgICAgICAgICAgIHR5cGU6ICdib29sZWFuJyxcbiAgICAgICAgICB9LFxuICAgICAgICB9LFxuICAgICAgICBhZGRpdGlvbmFsUHJvcGVydGllczogZmFsc2UsXG4gICAgICB9LFxuICAgIF0sXG4gIH0sXG5cbiAgY3JlYXRlKGNvbnRleHQpIHtcbiAgICBjb25zdCBvcHRpb25zID0gY29udGV4dC5vcHRpb25zWzBdIHx8IHt9O1xuXG4gICAgZnVuY3Rpb24gY2hlY2tTcGVjaWZpZXJzKGtleSwgdHlwZSwgbm9kZSkge1xuICAgICAgLy8gaWdub3JlIGxvY2FsIGV4cG9ydHMgYW5kIHR5cGUgaW1wb3J0cy9leHBvcnRzXG4gICAgICBpZiAoXG4gICAgICAgIG5vZGUuc291cmNlID09IG51bGxcbiAgICAgICAgfHwgbm9kZS5pbXBvcnRLaW5kID09PSAndHlwZSdcbiAgICAgICAgfHwgbm9kZS5pbXBvcnRLaW5kID09PSAndHlwZW9mJ1xuICAgICAgICB8fCBub2RlLmV4cG9ydEtpbmQgPT09ICd0eXBlJ1xuICAgICAgKSB7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgaWYgKCFub2RlLnNwZWNpZmllcnMuc29tZSgoaW0pID0+IGltLnR5cGUgPT09IHR5cGUpKSB7XG4gICAgICAgIHJldHVybjsgLy8gbm8gbmFtZWQgaW1wb3J0cy9leHBvcnRzXG4gICAgICB9XG5cbiAgICAgIGNvbnN0IGltcG9ydHMgPSBFeHBvcnRzLmdldChub2RlLnNvdXJjZS52YWx1ZSwgY29udGV4dCk7XG4gICAgICBpZiAoaW1wb3J0cyA9PSBudWxsIHx8IGltcG9ydHMucGFyc2VHb2FsID09PSAnYW1iaWd1b3VzJykge1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG5cbiAgICAgIGlmIChpbXBvcnRzLmVycm9ycy5sZW5ndGgpIHtcbiAgICAgICAgaW1wb3J0cy5yZXBvcnRFcnJvcnMoY29udGV4dCwgbm9kZSk7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgbm9kZS5zcGVjaWZpZXJzLmZvckVhY2goZnVuY3Rpb24gKGltKSB7XG4gICAgICAgIGlmIChcbiAgICAgICAgICBpbS50eXBlICE9PSB0eXBlXG4gICAgICAgICAgLy8gaWdub3JlIHR5cGUgaW1wb3J0c1xuICAgICAgICAgIHx8IGltLmltcG9ydEtpbmQgPT09ICd0eXBlJyB8fCBpbS5pbXBvcnRLaW5kID09PSAndHlwZW9mJ1xuICAgICAgICApIHtcbiAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCBuYW1lID0gaW1ba2V5XS5uYW1lIHx8IGltW2tleV0udmFsdWU7XG5cbiAgICAgICAgY29uc3QgZGVlcExvb2t1cCA9IGltcG9ydHMuaGFzRGVlcChuYW1lKTtcblxuICAgICAgICBpZiAoIWRlZXBMb29rdXAuZm91bmQpIHtcbiAgICAgICAgICBpZiAoZGVlcExvb2t1cC5wYXRoLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgIGNvbnN0IGRlZXBQYXRoID0gZGVlcExvb2t1cC5wYXRoXG4gICAgICAgICAgICAgIC5tYXAoaSA9PiBwYXRoLnJlbGF0aXZlKHBhdGguZGlybmFtZShjb250ZXh0LmdldFBoeXNpY2FsRmlsZW5hbWUgPyBjb250ZXh0LmdldFBoeXNpY2FsRmlsZW5hbWUoKSA6IGNvbnRleHQuZ2V0RmlsZW5hbWUoKSksIGkucGF0aCkpXG4gICAgICAgICAgICAgIC5qb2luKCcgLT4gJyk7XG5cbiAgICAgICAgICAgIGNvbnRleHQucmVwb3J0KGltW2tleV0sIGAke25hbWV9IG5vdCBmb3VuZCB2aWEgJHtkZWVwUGF0aH1gKTtcbiAgICAgICAgICB9IGVsc2Uge1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0aFxuICAgICAgICAgICAgICAubWFwKGkgPT4gcGF0aC5yZWxhdGl2ZShwYXRoLmRpcm5hbWUoY29udGV4dC5nZXRGaWxlbmFtZSgpKSwgaS5wYXRoKSlcbiAgICAgICAgICAgICAgLmpvaW4oJyAtPiAnKTtcblxuICAgICAgICAgICAgY29udGV4dC5yZXBvcnQoaW0ua2V5LCBgJHtpbS5rZXkubmFtZX0gbm90IGZvdW5kIHZpYSAke2RlZXBQYXRofWApO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb250ZXh0LnJlcG9ydChpbS5rZXksIGltLmtleS5uYW1lICsgJyBub3QgZm91bmQgaW4gXFwnJyArIHNvdXJjZS52YWx1ZSArICdcXCcnKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICAgIH1cblxuICAgIHJldHVybiB7XG4gICAgICBJbXBvcnREZWNsYXJhdGlvbjogY2hlY2tTcGVjaWZpZXJzLmJpbmQobnVsbCwgJ2ltcG9ydGVkJywgJ0ltcG9ydFNwZWNpZmllcicpLFxuXG4gICAgICBFeHBvcnROYW1lZERlY2xhcmF0aW9uOiBjaGVja1NwZWNpZmllcnMuYmluZChudWxsLCAnbG9jYWwnLCAnRXhwb3J0U3BlY2lmaWVyJyksXG5cbiAgICAgIFZhcmlhYmxlRGVjbGFyYXRvcjogY2hlY2tSZXF1aXJlLFxuICAgIH07XG4gIH0sXG59O1xuIl19