'use strict';var _declaredScope = require('eslint-module-utils/declaredScope');var _declaredScope2 = _interopRequireDefault(_declaredScope); 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 message(deprecation) { return 'Deprecated' + (deprecation.description ? ': ' + deprecation.description : '.'); } function getDeprecation(metadata) { if (!metadata || !metadata.doc) return; return metadata.doc.tags.find(t => t.title === 'deprecated'); } module.exports = { meta: { type: 'suggestion', docs: { url: (0, _docsUrl2.default)('no-deprecated') }, schema: [] }, create: function (context) { const deprecated = new Map(); const 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; const moduleDeprecation = imports.doc && imports.doc.tags.find(t => t.title === 'deprecated'); if (moduleDeprecation) { context.report({ node, message: message(moduleDeprecation) }); } if (imports.errors.length) { imports.reportErrors(context, node); return; } node.specifiers.forEach(function (im) { let imported;let 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 let namespace = namespaces.get(dereference.object.name); const 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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1kZXByZWNhdGVkLmpzIl0sIm5hbWVzIjpbIm1lc3NhZ2UiLCJkZXByZWNhdGlvbiIsImRlc2NyaXB0aW9uIiwiZ2V0RGVwcmVjYXRpb24iLCJtZXRhZGF0YSIsImRvYyIsInRhZ3MiLCJmaW5kIiwidCIsInRpdGxlIiwibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJkZXByZWNhdGVkIiwiTWFwIiwibmFtZXNwYWNlcyIsImNoZWNrU3BlY2lmaWVycyIsIm5vZGUiLCJzb3VyY2UiLCJpbXBvcnRzIiwiRXhwb3J0cyIsImdldCIsInZhbHVlIiwibW9kdWxlRGVwcmVjYXRpb24iLCJyZXBvcnQiLCJlcnJvcnMiLCJsZW5ndGgiLCJyZXBvcnRFcnJvcnMiLCJzcGVjaWZpZXJzIiwiZm9yRWFjaCIsImltIiwiaW1wb3J0ZWQiLCJsb2NhbCIsInNpemUiLCJzZXQiLCJuYW1lIiwiZXhwb3J0ZWQiLCJuYW1lc3Bh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24gPSBnZXREZXByZWNhdGlvbihpbXBvcnRzLmdldChpbXBvcnRlZCkpO1xuICAgICAgICBpZiAoIWRlcHJlY2F0aW9uKSByZXR1cm47XG5cbiAgICAgICAgY29udGV4dC5yZXBvcnQoeyBub2RlOiBpbSwgbWVzc2FnZTogbWVzc2FnZShkZXByZWNhdGlvbikgfSk7XG5cbiAgICAgICAgZGVwcmVjYXRlZC5zZXQobG9jYWwsIGRlcHJlY2F0aW9uKTtcblxuICAgICAgfSk7XG4gICAgfVxuXG4gICAgcmV0dXJuIHtcbiAgICAgICdQcm9ncmFtJzogKHsgYm9keSB9KSA9PiBib2R5LmZvckVhY2goY2hlY2tTcGVjaWZpZXJzKSxcblxuICAgICAgJ0lkZW50aWZpZXInOiBmdW5jdGlvbiAobm9kZSkge1xuICAgICAgICBpZiAobm9kZS5wYXJlbnQudHlwZSA9PT0gJ01lbWJlckV4cHJlc3Npb24nICYmIG5vZGUucGFyZW50LnByb3BlcnR5ID09PSBub2RlKSB7XG4gICAgICAgICAgcmV0dXJuOyAvLyBoYW5kbGVkIGJ5IE1lbWJlckV4cHJlc3Npb25cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIGlnbm9yZSBzcGVjaWZpZXIgaWRlbnRpZmllcnNcbiAgICAgICAgaWYgKG5vZGUucGFyZW50LnR5cGUuc2xpY2UoMCwgNikgPT09ICdJbXBvcnQnKSByZXR1cm47XG5cbiAgICAgICAgaWYgKCFkZXByZWNhdGVkLmhhcyhub2RlLm5hbWUpKSByZXR1cm47XG5cbiAgICAgICAgaWYgKGRlY2xhcmVkU2NvcGUoY29udGV4dCwgbm9kZS5uYW1lKSAhPT0gJ21vZHVsZScpIHJldHVybjtcbiAgICAgICAgY29udGV4dC5yZXBvcnQoe1xuICAgICAgICAgIG5vZGUsXG4gICAgICAgICAgbWVzc2FnZTogbWVzc2FnZShkZXByZWNhdGVkLmdldChub2RlLm5hbWUpKSxcbiAgICAgICAgfSk7XG4gICAgICB9LFxuXG4gICAgICA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