'use strict'; var _ExportMap = require('../ExportMap'); var _ExportMap2 = _interopRequireDefault(_ExportMap); var _declaredScope = require('eslint-module-utils/declaredScope'); var _declaredScope2 = _interopRequireDefault(_declaredScope); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function message(deprecation) { return 'Deprecated' + (deprecation.description ? ': ' + deprecation.description : '.'); } function getDeprecation(metadata) { if (!metadata || !metadata.doc) return; let deprecation; if (metadata.doc.tags.some(t => t.title === 'deprecated' && (deprecation = t))) { return deprecation; } } module.exports = { meta: { docs: {} }, create: function (context) { const deprecated = new Map(), namespaces = new Map(); function checkSpecifiers(node) { if (node.type !== 'ImportDeclaration') return; if (node.source == null) return; // local export, ignore const imports = _ExportMap2.default.get(node.source.value, context); if (imports == null) return; let moduleDeprecation; if (imports.doc && imports.doc.tags.some(t => t.title === 'deprecated' && (moduleDeprecation = t))) { context.report({ node, message: message(moduleDeprecation) }); } if (imports.errors.length) { imports.reportErrors(context, node); return; } node.specifiers.forEach(function (im) { let imported, local; switch (im.type) { case 'ImportNamespaceSpecifier': { if (!imports.size) return; namespaces.set(im.local.name, imports); return; } case 'ImportDefaultSpecifier': imported = 'default'; local = im.local.name; break; case 'ImportSpecifier': imported = im.imported.name; local = im.local.name; break; default: return; // can't handle this one } // unknown thing can't be deprecated const exported = imports.get(imported); if (exported == null) return; // capture import of deep namespace if (exported.namespace) namespaces.set(local, exported.namespace); const deprecation = getDeprecation(imports.get(imported)); if (!deprecation) return; context.report({ node: im, message: message(deprecation) }); deprecated.set(local, deprecation); }); } return { 'Program': (_ref) => { let body = _ref.body; return body.forEach(checkSpecifiers); }, 'Identifier': function (node) { if (node.parent.type === 'MemberExpression' && node.parent.property === node) { return; // handled by MemberExpression } // ignore specifier identifiers if (node.parent.type.slice(0, 6) === 'Import') return; if (!deprecated.has(node.name)) return; if ((0, _declaredScope2.default)(context, node.name) !== 'module') return; context.report({ node, message: message(deprecated.get(node.name)) }); }, 'MemberExpression': function (dereference) { if (dereference.object.type !== 'Identifier') return; if (!namespaces.has(dereference.object.name)) return; if ((0, _declaredScope2.default)(context, dereference.object.name) !== 'module') return; // go deep var namespace = namespaces.get(dereference.object.name); var namepath = [dereference.object.name]; // while property is namespace and parent is member expression, keep validating while (namespace instanceof _ExportMap2.default && dereference.type === 'MemberExpression') { // ignore computed parts for now if (dereference.computed) return; const metadata = namespace.get(dereference.property.name); if (!metadata) break; const deprecation = getDeprecation(metadata); if (deprecation) { context.report({ node: dereference.property, message: message(deprecation) }); } // stash and pop namepath.push(dereference.property.name); namespace = metadata.namespace; dereference = dereference.parent; } } }; } }; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vLWRlcHJlY2F0ZWQuanMiXSwibmFtZXMiOlsibWVzc2FnZSIsImRlcHJlY2F0aW9uIiwiZGVzY3JpcHRpb24iLCJnZXREZXByZWNhdGlvbiIsIm1ldGFkYXRhIiwiZG9jIiwidGFncyIsInNvbWUiLCJ0IiwidGl0bGUiLCJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsImRvY3MiLCJjcmVhdGUiLCJjb250ZXh0IiwiZGVwcmVjYXRlZCIsIk1hcCIsIm5hbWVzcGFjZXMiLCJjaGVja1NwZWNpZmllcnMiLCJub2RlIiwidHlwZSIsInNvdXJjZSIsImltcG9ydHMiLCJnZXQiLCJ2YWx1ZSIsIm1vZHVsZURlcHJlY2F0aW9uIiwicmVwb3J0IiwiZXJyb3JzIiwibGVuZ3RoIiwicmVwb3J0RXJyb3JzIiwic3BlY2lmaWVycyIsImZvckVhY2giLCJpbSIsImltcG9ydGVkIiwibG9jYWwiLCJzaXplIiwic2V0IiwibmFtZSIsImV4cG9ydGVkIiwibmFtZXNwYWNlIiwiYm9keSIsInBhcmVudCIsInByb3BlcnR5Iiwic2xpY2UiLCJoYXMiLCJkZXJlZmVyZW5jZSIsIm9iamVjdCIsIm5hbWVwYXRoIiwiY29tcHV0ZWQi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