mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
139 lines
16 KiB
JavaScript
139 lines
16 KiB
JavaScript
'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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1kZXByZWNhdGVkLmpzIl0sIm5hbWVzIjpbIm1lc3NhZ2UiLCJkZXByZWNhdGlvbiIsImRlc2NyaXB0aW9uIiwiZ2V0RGVwcmVjYXRpb24iLCJtZXRhZGF0YSIsImRvYyIsInRhZ3MiLCJmaW5kIiwidCIsInRpdGxlIiwibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJkZXByZWNhdGVkIiwiTWFwIiwibmFtZXNwYWNlcyIsImNoZWNrU3BlY2lmaWVycyIsIm5vZGUiLCJzb3VyY2UiLCJpbXBvcnRzIiwiRXhwb3J0cyIsImdldCIsInZhbHVlIiwibW9kdWxlRGVwcmVjYXRpb24iLCJyZXBvcnQiLCJlcnJvcnMiLCJsZW5ndGgiLCJyZXBvcnRFcnJvcnMiLCJzcGVjaWZpZXJzIiwiZm9yRWFjaCIsImltIiwiaW1wb3J0ZWQiLCJsb2NhbCIsInNpemUiLCJzZXQiLCJuYW1lIiwiZXhwb3J0ZWQiLCJuYW1lc3BhY2UiLCJib2R5IiwicGFyZW50IiwicHJvcGVydHkiLCJzbGljZSIsImhhcyIsImRlcmVmZXJlbmNlIiwib2JqZWN0IiwibmFtZXBhdGgiLCJjb21wdXRlZCIsInB1c2giXSwibWFwcGluZ3MiOiJhQUFBLGtFO0FBQ0EseUM7QUFDQSxxQzs7QUFFQSxTQUFTQSxPQUFULENBQWlCQyxXQUFqQixFQUE4QjtBQUM1QixTQUFPLGdCQUF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OntcbiAgICAgICAgICBpZiAoIWltcG9ydHMuc2l6ZSkgcmV0dXJuO1xuICAgICAgICAgIG5hbWVzcGFjZXMuc2V0KGltLmxvY2FsLm5hbWUsIGltcG9ydHMpO1xuICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGNhc2UgJ0ltcG9ydERlZmF1bHRTcGVjaWZpZXInOlxuICAgICAgICAgIGltcG9ydGVkID0gJ2RlZmF1bHQnO1xuICAgICAgICAgIGxvY2FsID0gaW0ubG9jYWwubmFtZTtcbiAgICAgICAgICBicmVhaztcblxuICAgICAgICBjYXNlICdJbXBvcnRTcGVjaWZpZXInOlxuICAgICAgICAgIGltcG9ydGVkID0gaW0uaW1wb3J0ZWQubmFtZTtcbiAgICAgICAgICBsb2NhbCA9IGltLmxvY2FsLm5hbWU7XG4gICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgZGVmYXVsdDogcmV0dXJuOyAvLyBjYW4ndCBoYW5kbGUgdGhpcyBvbmVcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIHVua25vd24gdGhpbmcgY2FuJ3QgYmUgZGVwcmVjYXRlZFxuICAgICAgICBjb25zdCBleHBvcnRlZCA9IGltcG9ydHMuZ2V0KGltcG9ydGVkKTtcbiAgICAgICAgaWYgKGV4cG9ydGVkID09IG51bGwpIHJldHVybjtcblxuICAgICAgICAvLyBjYXB0dXJlIGltcG9ydCBvZiBkZWVwIG5hbWVzcGFjZVxuICAgICAgICBpZiAoZXhwb3J0ZWQubmFtZXNwYWNlKSBuYW1lc3BhY2VzLnNldChsb2NhbCwgZXhwb3J0ZWQubmFtZXNwYWNlKTtcblxuICAgICAgICBjb25zdCBkZXByZWNhdGlvbiA9IGdldERlcHJlY2F0aW9uKGltcG9ydHMuZ2V0KGltcG9ydGVkKSk7XG4gICAgICAgIGlmICghZGVwcmVjYXRpb24pIHJldHVybjtcblxuICAgICAgICBjb250ZXh0LnJlcG9ydCh7IG5vZGU6IGltLCBtZXNzY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