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) {
-
- 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;
- }
- 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;
-
- 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') };
- } };
|