'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; let deprecation; if (metadata.doc.tags.some(t => t.title === 'deprecated' && (deprecation = t))) { return deprecation; } } module.exports = { meta: { docs: { url: (0, _docsUrl2.default)('no-deprecated') } }, 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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vLWRlcHJlY2F0ZWQuanMiXSwibmFtZXMiOlsibWVzc2FnZSIsImRlcHJlY2F0aW9uIiwiZGVzY3JpcHRpb24iLCJnZXREZXByZWNhdGlvbiIsIm1ldGFkYXRhIiwiZG9jIiwidGFncyIsInNvbWUiLCJ0IiwidGl0bGUiLCJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsImRvY3MiLCJ1cmwiLCJjcmVhdGUiLCJjb250ZXh0IiwiZGVwcmVjYXRlZCIsIk1hcCIsIm5hbWVzcGFjZXMiLCJjaGVja1NwZWNpZmllcnMiLCJub2RlIiwidHlwZSIsInNvdXJjZSIsImltcG9ydHMiLCJFeHBvcnRzIiwiZ2V0IiwidmFsdWUiLCJtb2R1bGVEZXByZWNhdGlvbiIsInJlcG9ydCIsImVycm9ycyIsImxlbmd0aCIsInJlcG9ydEVycm9ycyIsInNwZWNpZmllcnMiLCJmb3JFYWNoIiwiaW0iLCJpbXBvcnRlZCIsImxvY2FsIiwic2l6ZSIsInNldCIsIm5hbWUiLCJleHBvcnRlZCIsIm5hbWVzcGFjZSIsImJvZHkiLCJwYXJlb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RFcnJvcnMoY29udGV4dCwgbm9kZSlcbiAgICAgICAgcmV0dXJuXG4gICAgICB9XG5cbiAgICAgIG5vZGUuc3BlY2lmaWVycy5mb3JFYWNoKGZ1bmN0aW9uIChpbSkge1xuICAgICAgICBsZXQgaW1wb3J0ZWQsIGxvY2FsXG4gICAgICAgIHN3aXRjaCAoaW0udHlwZSkge1xuXG5cbiAgICAgICAgICBjYXNlICdJbXBvcnROYW1lc3BhY2VTcGVjaWZpZXInOntcbiAgICAgICAgICAgIGlmICghaW1wb3J0cy5zaXplKSByZXR1cm5cbiAgICAgICAgICAgIG5hbWVzcGFjZXMuc2V0KGltLmxvY2FsLm5hbWUsIGltcG9ydHMpXG4gICAgICAgICAgICByZXR1cm5cbiAgICAgICAgICB9XG5cbiAgICAgICAgICBjYXNlICdJbXBvcnREZWZhdWx0U3BlY2lmaWVyJzpcbiAgICAgICAgICAgIGltcG9ydGVkID0gJ2RlZmF1bHQnXG4gICAgICAgICAgICBsb2NhbCA9IGltLmxvY2FsLm5hbWVcbiAgICAgICAgICAgIGJyZWFrXG5cbiAgICAgICAgICBjYXNlICdJbXBvcnRTcGVjaWZpZXInOlxuICAgICAgICAgICAgaW1wb3J0ZWQgPSBpbS5pbXBvcnRlZC5uYW1lXG4gICAgICAgICAgICBsb2NhbCA9IGltLmxvY2FsLm5hbWVcbiAgICAgICAgICAgIGJyZWFrXG5cbiAgICAgICAgICBkZWZhdWx0OiByZXR1cm4gLy8gY2FuJ3QgaGFuZGxlIHRoaXMgb25lXG4gICAgICAgIH1cblxuICAgICAgICAvLyB1bmtub3duIHRoaW5nIGNhbid0IGJlIGRlcHJlY2F0ZWRcbiAgICAgICAgY29uc3QgZXhwb3J0ZWQgPSBpbXBvcnRzLmdldChpbXBvcnRlZClcbiAgICAgICAgaWYgKGV4cG9ydGVkID09IG51bGwpIHJldHVyblxuXG4gICAgICAgIC8vIGNhcHR1cmUgaW1wb3J0IG9mIGRlZXAgbmFtZXNwYWNlXG4gICAgICAgI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