You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
16 KiB
139 lines
16 KiB
'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(function (t) {return t.title === 'deprecated';}); |
|
} |
|
|
|
module.exports = { |
|
meta: { |
|
type: 'suggestion', |
|
docs: { |
|
url: (0, _docsUrl2['default'])('no-deprecated') }, |
|
|
|
schema: [] }, |
|
|
|
|
|
create: function () {function create(context) { |
|
var deprecated = new Map(); |
|
var namespaces = new Map(); |
|
|
|
function checkSpecifiers(node) { |
|
if (node.type !== 'ImportDeclaration') return; |
|
if (node.source == null) return; // local export, ignore |
|
|
|
var imports = _ExportMap2['default'].get(node.source.value, context); |
|
if (imports == null) return; |
|
|
|
var moduleDeprecation = imports.doc && imports.doc.tags.find(function (t) {return t.title === 'deprecated';}); |
|
if (moduleDeprecation) { |
|
context.report({ node: node, message: message(moduleDeprecation) }); |
|
} |
|
|
|
if (imports.errors.length) { |
|
imports.reportErrors(context, node); |
|
return; |
|
} |
|
|
|
node.specifiers.forEach(function (im) { |
|
var imported = void 0;var local = void 0; |
|
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 |
|
var exported = imports.get(imported); |
|
if (exported == null) return; |
|
|
|
// capture import of deep namespace |
|
if (exported.namespace) namespaces.set(local, exported.namespace); |
|
|
|
var deprecation = getDeprecation(imports.get(imported)); |
|
if (!deprecation) return; |
|
|
|
context.report({ node: im, message: message(deprecation) }); |
|
|
|
deprecated.set(local, deprecation); |
|
|
|
}); |
|
} |
|
|
|
return { |
|
'Program': function () {function Program(_ref) {var body = _ref.body;return body.forEach(checkSpecifiers);}return Program;}(), |
|
|
|
'Identifier': function () {function Identifier(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: node, |
|
message: message(deprecated.get(node.name)) }); |
|
|
|
}return Identifier;}(), |
|
|
|
'MemberExpression': function () {function MemberExpression(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; |
|
|
|
var metadata = namespace.get(dereference.property.name); |
|
|
|
if (!metadata) break; |
|
var 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; |
|
} |
|
}return MemberExpression;}() }; |
|
|
|
}return create;}() }; |
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1kZXByZWNhdGVkLmpzIl0sIm5hbWVzIjpbIm1lc3NhZ2UiLCJkZXByZWNhdGlvbiIsImRlc2NyaXB0aW9uIiwiZ2V0RGVwcmVjYXRpb24iLCJtZXRhZGF0YSIsImRvYyIsInRhZ3MiLCJmaW5kIiwidCIsInRpdGxlIiwibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJkZXByZWNhdGVkIiwiTWFwIiwibmFtZXNwYWNlcyIsImNoZWNrU3BlY2lmaWVycyIsIm5vZGUiLCJzb3VyY2UiLCJpbXBvcnRzIiwiRXhwb3J0cyIsImdldCIsInZhbHVlIiwibW9kdWxlRGVwcmVjYXRpb24iLCJyZXBvcnQiLCJlcnJvcnMiLCJsZW5ndGgiLCJyZXBvcnRFcnJvcnMiLCJzcGVjaWZpZXJzIiwiZm9yRWFjaCIsImltIiwiaW1wb3J0ZWQiLCJsb2NhbCIsInNpemUiLCJzZXQiLCJuYW1lIiwiZXhwb3J0ZWQiLCJuYW1lc3BhY2UiLCJib2R5IiwicGFyZW50IiwicHJvcGVydHkiLCJzbGljZSIsImhhcyIsImRlcmVmZXJlbmNlIiwib2JqZWN0IiwibmFtZXBhdGgiLCJjb21wdXRlZCIsInB1c2giXSwibWFwcGluZ3MiOiJhQUFBLGtFO0FBQ0EseUM7QUFDQSxxQzs7QUFFQSxTQUFTQSxPQUFULENBQWlCQyxXQUFqQixFQUE4QjtBQUM1QixTQUFPLGdCQUFnQkEsWUFBWUMsV0FBWixHQUEwQixPQUFPRCxZQUFZQyxXQUE3QyxHQUEyRCxHQUEzRSxDQUFQO0FBQ0Q7O0FBRUQsU0FBU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