123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- 'use strict';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: [] },
- create: function (context) {
- 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
- }
- const 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) return;
- // ignore type imports
- if (im.importKind === 'type' || im.importKind === 'typeof') return;
- const deepLookup = imports.hasDeep(im[key].name);
- if (!deepLookup.found) {
- if (deepLookup.path.length > 1) {
- const deepPath = deepLookup.path.
- map(i => path.relative(path.dirname(context.getFilename()), i.path)).
- join(' -> ');
- context.report(im[key],
- `${im[key].name} not found via ${deepPath}`);
- } else {
- context.report(im[key],
- im[key].name + ' not found in \'' + node.source.value + '\'');
- }
- }
- });
- }
- return {
- 'ImportDeclaration': checkSpecifiers.bind(null,
- 'imported',
- 'ImportSpecifier'),
- 'ExportNamedDeclaration': checkSpecifiers.bind(null,
- 'local',
- 'ExportSpecifier') };
- } };
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLC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ICAgICAgIGNvbnN0IGRlZXBMb29rdXAgPSBpbXBvcnRzLmhhc0RlZXAoaW1ba2V5XS5uYW1lKTtcblxuICAgICAgICBpZiAoIWRlZXBMb29rdXAuZm91bmQpIHtcbiAgICAgICAgICBpZiAoZGVlcExvb2t1cC5wYXRoLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgIGNvbnN0IGRlZXBQYXRoID0gZGVlcExvb2t1cC5wYXRoXG4gICAgICAgICAgICAgIC5tYXAoaSA9PiBwYXRoLnJlbGF0aXZlKHBhdGguZGlybmFtZShjb250ZXh0LmdldEZpbGVuYW1lKCkpLCBpLnBhdGgpKVxuICAgICAgICAgICAgICAuam9pbignIC0+ICcpO1xuXG4gICAgICAgICAgICBjb250ZXh0LnJlcG9ydChpbVtrZXldLFxuICAgICAgICAgICAgICBgJHtpbVtrZXldLm5hbWV9IG5vdCBmb3VuZCB2aWEgJHtkZWVwUGF0aH1gKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29udGV4dC5yZXBvcnQoaW1ba2V5XSxcbiAgICAgICAgICAgICAgaW1ba2V5XS5uYW1lICsgJyBub3QgZm91bmQgaW4gXFwnJyArIG5vZGUuc291cmNlLnZhbHVlICsgJ1xcJycpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgfVxuXG4gICAgcmV0dXJuIHtcbiAgICAgICdJbXBvcnREZWNsYXJhdGlvbic6IGNoZWNrU3BlY2lmaWVycy5iaW5kKCBudWxsXG4gICAgICAgICwgJ2ltcG9ydGVkJ1xuICAgICAgICAsICdJbXBvcnRTcGVjaWZpZXInXG4gICAgICApLFxuXG4gICAgICAnRXhwb3J0TmFtZWREZWNsYXJhdGlvbic6IGNoZWNrU3BlY2lmaWVycy5iaW5kKCBudWxsXG4gICAgICAgICwgJ2xvY2FsJ1xuICAgICAgICAsICdFeHBvcnRTcGVjaWZpZXInXG4gICAgICApLFxuICAgIH07XG5cbiAgfSxcbn07XG4iXX0=
|