mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-26 10:25:14 +00:00
217 lines
26 KiB
JavaScript
217 lines
26 KiB
JavaScript
'use strict';var _declaredScope = require('eslint-module-utils/declaredScope');var _declaredScope2 = _interopRequireDefault(_declaredScope);
|
|
var _ExportMap = require('../ExportMap');var _ExportMap2 = _interopRequireDefault(_ExportMap);
|
|
var _importDeclaration = require('../importDeclaration');var _importDeclaration2 = _interopRequireDefault(_importDeclaration);
|
|
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'problem',
|
|
docs: {
|
|
url: (0, _docsUrl2['default'])('namespace') },
|
|
|
|
|
|
schema: [
|
|
{
|
|
type: 'object',
|
|
properties: {
|
|
allowComputed: {
|
|
description: 'If `false`, will report computed (and thus, un-lintable) references to namespace members.',
|
|
type: 'boolean',
|
|
'default': false } },
|
|
|
|
|
|
additionalProperties: false }] },
|
|
|
|
|
|
|
|
|
|
create: function () {function namespaceRule(context) {
|
|
|
|
// read options
|
|
var _ref =
|
|
|
|
context.options[0] || {},_ref$allowComputed = _ref.allowComputed,allowComputed = _ref$allowComputed === undefined ? false : _ref$allowComputed;
|
|
|
|
var namespaces = new Map();
|
|
|
|
function makeMessage(last, namepath) {
|
|
return '\'' + String(last.name) + '\' not found in ' + (namepath.length > 1 ? 'deeply ' : '') + 'imported namespace \'' + String(namepath.join('.')) + '\'.';
|
|
}
|
|
|
|
return {
|
|
// pick up all imports at body entry time, to properly respect hoisting
|
|
Program: function () {function Program(_ref2) {var body = _ref2.body;
|
|
function processBodyStatement(declaration) {
|
|
if (declaration.type !== 'ImportDeclaration') return;
|
|
|
|
if (declaration.specifiers.length === 0) return;
|
|
|
|
var imports = _ExportMap2['default'].get(declaration.source.value, context);
|
|
if (imports == null) return null;
|
|
|
|
if (imports.errors.length) {
|
|
imports.reportErrors(context, declaration);
|
|
return;
|
|
}var _iteratorNormalCompletion = true;var _didIteratorError = false;var _iteratorError = undefined;try {
|
|
|
|
for (var _iterator = declaration.specifiers[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {var specifier = _step.value;
|
|
switch (specifier.type) {
|
|
case 'ImportNamespaceSpecifier':
|
|
if (!imports.size) {
|
|
context.report(
|
|
specifier, 'No exported names found in module \'' + String(
|
|
declaration.source.value) + '\'.');
|
|
|
|
}
|
|
namespaces.set(specifier.local.name, imports);
|
|
break;
|
|
case 'ImportDefaultSpecifier':
|
|
case 'ImportSpecifier':{
|
|
var meta = imports.get(
|
|
// default to 'default' for default http://i.imgur.com/nj6qAWy.jpg
|
|
specifier.imported ? specifier.imported.name : 'default');
|
|
|
|
if (!meta || !meta.namespace) {break;}
|
|
namespaces.set(specifier.local.name, meta.namespace);
|
|
break;
|
|
}}
|
|
|
|
}} catch (err) {_didIteratorError = true;_iteratorError = err;} finally {try {if (!_iteratorNormalCompletion && _iterator['return']) {_iterator['return']();}} finally {if (_didIteratorError) {throw _iteratorError;}}}
|
|
}
|
|
body.forEach(processBodyStatement);
|
|
}return Program;}(),
|
|
|
|
// same as above, but does not add names to local map
|
|
ExportNamespaceSpecifier: function () {function ExportNamespaceSpecifier(namespace) {
|
|
var declaration = (0, _importDeclaration2['default'])(context);
|
|
|
|
var imports = _ExportMap2['default'].get(declaration.source.value, context);
|
|
if (imports == null) return null;
|
|
|
|
if (imports.errors.length) {
|
|
imports.reportErrors(context, declaration);
|
|
return;
|
|
}
|
|
|
|
if (!imports.size) {
|
|
context.report(
|
|
namespace, 'No exported names found in module \'' + String(
|
|
declaration.source.value) + '\'.');
|
|
|
|
}
|
|
}return ExportNamespaceSpecifier;}(),
|
|
|
|
// todo: check for possible redefinition
|
|
|
|
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;
|
|
|
|
if (dereference.parent.type === 'AssignmentExpression' && dereference.parent.left === dereference) {
|
|
context.report(
|
|
dereference.parent, 'Assignment to member of namespace \'' + String(
|
|
dereference.object.name) + '\'.');
|
|
|
|
}
|
|
|
|
// 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') {
|
|
|
|
if (dereference.computed) {
|
|
if (!allowComputed) {
|
|
context.report(
|
|
dereference.property, 'Unable to validate computed reference to imported namespace \'' + String(
|
|
dereference.object.name) + '\'.');
|
|
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (!namespace.has(dereference.property.name)) {
|
|
context.report(
|
|
dereference.property,
|
|
makeMessage(dereference.property, namepath));
|
|
|
|
break;
|
|
}
|
|
|
|
var exported = namespace.get(dereference.property.name);
|
|
if (exported == null) return;
|
|
|
|
// stash and pop
|
|
namepath.push(dereference.property.name);
|
|
namespace = exported.namespace;
|
|
dereference = dereference.parent;
|
|
}
|
|
|
|
}return MemberExpression;}(),
|
|
|
|
VariableDeclarator: function () {function VariableDeclarator(_ref3) {var id = _ref3.id,init = _ref3.init;
|
|
if (init == null) return;
|
|
if (init.type !== 'Identifier') return;
|
|
if (!namespaces.has(init.name)) return;
|
|
|
|
// check for redefinition in intermediate scopes
|
|
if ((0, _declaredScope2['default'])(context, init.name) !== 'module') return;
|
|
|
|
// DFS traverse child namespaces
|
|
function testKey(pattern, namespace) {var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [init.name];
|
|
if (!(namespace instanceof _ExportMap2['default'])) return;
|
|
|
|
if (pattern.type !== 'ObjectPattern') return;var _iteratorNormalCompletion2 = true;var _didIteratorError2 = false;var _iteratorError2 = undefined;try {
|
|
|
|
for (var _iterator2 = pattern.properties[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {var property = _step2.value;
|
|
if (
|
|
property.type === 'ExperimentalRestProperty' ||
|
|
property.type === 'RestElement' ||
|
|
!property.key)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (property.key.type !== 'Identifier') {
|
|
context.report({
|
|
node: property,
|
|
message: 'Only destructure top-level names.' });
|
|
|
|
continue;
|
|
}
|
|
|
|
if (!namespace.has(property.key.name)) {
|
|
context.report({
|
|
node: property,
|
|
message: makeMessage(property.key, path) });
|
|
|
|
continue;
|
|
}
|
|
|
|
path.push(property.key.name);
|
|
var dependencyExportMap = namespace.get(property.key.name);
|
|
// could be null when ignored or ambiguous
|
|
if (dependencyExportMap !== null) {
|
|
testKey(property.value, dependencyExportMap.namespace, path);
|
|
}
|
|
path.pop();
|
|
}} catch (err) {_didIteratorError2 = true;_iteratorError2 = err;} finally {try {if (!_iteratorNormalCompletion2 && _iterator2['return']) {_iterator2['return']();}} finally {if (_didIteratorError2) {throw _iteratorError2;}}}
|
|
}
|
|
|
|
testKey(id, namespaces.get(init.name));
|
|
}return VariableDeclarator;}(),
|
|
|
|
JSXMemberExpression: function () {function JSXMemberExpression(_ref4) {var object = _ref4.object,property = _ref4.property;
|
|
if (!namespaces.has(object.name)) return;
|
|
var namespace = namespaces.get(object.name);
|
|
if (!namespace.has(property.name)) {
|
|
context.report({
|
|
node: property,
|
|
message: makeMessage(property, [object.name]) });
|
|
|
|
}
|
|
}return JSXMemberExpression;}() };
|
|
|
|
}return namespaceRule;}() };
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uYW1lc3BhY2UuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsInByb3BlcnRpZXMiLCJhbGxvd0NvbXB1dGVkIiwiZ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gICAgIGltcG9ydHMucmVwb3J0RXJyb3JzKGNvbnRleHQsIGRlY2xhcmF0aW9uKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBmb3IgKGNvbnN0IHNwZWNpZmllciBvZiBkZWNsYXJhdGlvbi5zcGVjaWZpZXJzKSB7XG4gICAgICAgICAgICBzd2l0Y2ggKHNwZWNpZmllci50eXBlKSB7XG4gICAgICAgICAgICBjYXNlICdJbXBvcnROYW1lc3BhY2VTcGVjaWZpZXInOlxuICAgICAgICAgICAgICBpZiAoIWltcG9ydHMuc2l6ZSkge1xuICAgICAgICAgICAgICAgIGNvbnRleHQucmVwb3J0KFxuICAgICAgICAgICAgICAgICAgc3BlY2lmaWVyLFxuICAgICAgICAgICAgICAgICAgYE5vIGV4cG9ydGVkIG5hbWVzIGZvdW5kIGluIG1vZHVsZSAnJHtkZWNsYXJhdGlvbi5zb3VyY2UudmFsdWV9Jy5gXG4gICAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBuYW1lc3BhY2VzLnNldChzcGVjaWZpZXIubG9jYWwubmFtZSwgaW1wb3J0cyk7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnSW1wb3J0RGVmYXVsdFNwZWNpZmllcic6XG4gICAgICAgICAgICBjYXNlICdJbXBvcnRTcGVjaWZpZXInOiB7XG4gICAgICAgICAgICAgIGNvbnN0IG1ldGEgPSBpbXBvcnRzLmdldChcbiAgICAgICAgICAgICAgICAvLyBkZWZhdWx0IHRvICdkZWZhdWx0JyBmb3IgZGVmYXVsdCBodHRwOi8vaS5pbWd1ci5jb20vbmo2cUFXeS5qcGdcbiAgICAgICAgICAgICAgICBzcGVjaWZpZXIuaW1wb3J0ZWQgPyBzcGVjaWZpZXIuaW1wb3J0ZWQubmFtZSA6ICdkZWZhdWx0J1xuICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgICBpZiAoIW1ldGEgfHwgIW1ldGEubmFtZXNwYWNlKSB7IGJyZWFrOyB9XG4gICAgICAgICAgICAgIG5hbWVzcGFjZXMuc2V0KHNwZWNpZmllci5sb2NhbC5uYW1lLCBtZXRhLm5hbWVzcGFjZSk7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBib2R5LmZvckVhY2gocHJvY2Vzc0JvZHlTdGF0ZW1lbnQpO1xuICAgICAgfSxcblxuICAgICAgLy8gc2FtZSBhcyBhYm92ZSwgYnV0IGRvZXMgbm90IGFkZCBuYW1lcyB0byBsb2NhbCBtYXBcbiAgICAgIEV4cG9ydE5hbWVzcGFjZVNwZWNpZmllcihuYW1lc3BhY2UpIHtcbiAgICAgICAgY29uc3QgZGVjbGFyYXRpb24gPSBpbXBvcnREZWNsYXJhdGlvbihjb250ZXh0KTtcblxuICAgICAgICBjb25zdCBpbXBvcnRzID0gRXhwb3J0cy5nZXQoZGVjbGFyYXRpb24uc291cmNlLnZhbHVlLCBjb250ZXh0KTtcbiAgICAgICAgaWYgKGltcG9ydHMgPT0gbnVsbCkgcmV0dXJuIG51bGw7XG5cbiAgICAgICAgaWYgKGltcG9ydHMuZXJyb3JzLmxlbmd0aCkge1xuICAgICAgICAgIGltcG9ydHMucmVwb3J0RXJyb3JzKGNvbnRleHQsIGRlY2xhcmF0aW9uKTtcbiAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoIWltcG9ydHMuc2l6ZSkge1xuICAgICAgICAgIGNvbnRleHQucmVwb3J0KFxuICAgICAgICAgICAgbmFtZXNwYWNlLFxuICAgICAgICAgICAgYE5vIGV4cG9ydGVkIG5hbWVzIGZvdW5kIGluIG1vZHVsZSAnJHtkZWNsYXJhdGlvbi5zb3VyY2UudmFsdWV9Jy5gXG4gICAgICAgICAgKTtcbiAgICAgICAgfVxuICAgICAgfSxcblxuIC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lb2YgRXhwb3J0cyAmJiBkZXJlZmVyZW5jZS50eXBlID09PSAnTWVtYmVyRXhwcmVzc2lvbicpIHtcblxuICAgICAgICAgIGlmIChkZXJlZmVyZW5jZS5jb21wdXRlZCkge1xuICAgICAgICAgICAgaWYgKCFhbGxvd0NvbXB1dGVkKSB7XG4gICAgICAgICAgICAgIGNvbnRleHQucmVwb3J0KFxuICAgICAgICAgICAgICAgIGRlcmVmZXJlbmNlLnByb3BlcnR5LFxuICAgICAgICAgICAgICAgIGBVbmFibGUgdG8gdmFsaWRhdGUgY29tcHV0ZWQgcmVmZXJlbmNlIHRvIGltcG9ydGVkIG5hbWVzcGFjZSAnJHtkZXJlZmVyZW5jZS5vYmplY3QubmFtZX0nLmBcbiAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBpZiAoIW5hbWVzcGFjZS5oYXMoZGVyZWZlcmVuY2UucHJvcGVydHkubmFtZSkpIHtcbiAgICAgICAgICAgIGNvbnRleHQucmVwb3J0KFxuICAgICAgICAgICAgICBkZXJlZmVyZW5jZS5wcm9wZXJ0eSxcbiAgICAgICAgICAgICAgbWFrZU1lc3NhZ2UoZGVyZWZlcmVuY2UucHJvcGVydHksIG5hbWVwYXRoKVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGNvbnN0IGV4cG9ydGVkID0gbmFtZXNwYWNlLmdldChkZXJlZmVyZW5jZS5wcm9wZXJ0eS5uYW1lKTtcbiAgICAgICAgICBpZiAoZXhwb3J0ZWQgPT0gbnVsbCkgcmV0dXJuO1xuXG4gICAgICAgICAgLy8gc3Rhc2ggYW5kIHBvcFxuICAgICAgICAgIG5hbWVwYXRoLnB1c2goZGVyZWZlcmVuY2UucHJvcGVydHkubmFtZSk7XG4gICAgICAgICAgbmFtZXNwYWNlID0gZXhwb3J0ZWQubmFtZXNwYWNlO1xuICAgICAgICAgIGRlcmVmZXJlbmNlID0gZGVyZWZlcmVuY2UucGFyZW50O1xuICAgICAgICB9XG5cbiAgICAgIH0sXG5cbiAgICAgIFZhcmlhYmxlRGVjbGFyYXRvcih7IGlkLCBpbml0IH0pIHtcbiAgICAgICAgaWYgKGluaXQgPT0gbnVsbCkgcmV0dXJuO1xuICAgICAgICBpZiAoaW5pdC50eXBlICE9PSAnSWRlbnRpZmllcicpIHJldHVybjtcbiAgICAgICAgaWYgKCFuYW1lc3BhY2VzLmhhcyhpbml0Lm5hbWUpKSByZXR1cm47XG5cbiAgICAgICAgLy8gY2hlY2sgZm9yIHJlZGVmaW5pdGlvbiBpbiBpbnRlcm1lZGlhdGUgc2NvcGVzXG4gICAgICAgIGlmIChkZWNsYXJlZFNjb3BlKGNvbnRleHQsIGluaXQubmFtZSkgIT09ICdtb2R1bGUnKSByZXR1cm47XG5cbiAgICAgICAgLy8gREZTIHRyYXZlcnNlIGNoaWxkIG5hbWVzcGFjZXNcbiAgICAgICAgZnVuY3Rpb24gdGVzdEtleShwYXR0ZXJuLCBuYW1lc3BhY2UsIHBhdGggPSBbaW5pdC5uYW1lXSkge1xuICAgICAgICAgIGlmICghKG5hbWVzcGFjZSBpbnN0YW5jZW9mIEV4cG9ydHMpKSByZXR1cm47XG5cbiAgICAgICAgICBpZiAocGF0dGVybi50eXBlICE9PSAnT2JqZWN0UGF0dGVybicpIHJldHVybjtcblxuICAgICAgICAgIGZvciAoY29uc3QgcHJvcGVydHkgb2YgcGF0dGVybi5wcm9wZXJ0aWVzKSB7XG4gICAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAgIHByb3BlcnR5LnR5cGUgPT09ICdFeHBlcmltZW50YWxSZXN0UHJvcGVydHknXG4gICAgICAgICAgICAgIHx8IHByb3BlcnR5LnR5cGUgPT09ICdSZXN0RWxlbWVudCdcbiAgICAgICAgICAgICAgfHwgIXByb3BlcnR5LmtleVxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAocHJvcGVydHkua2V5LnR5cGUgIT09ICdJZGVudGlmaWVyJykge1xuICAgICAgICAgICAgICBjb250ZXh0LnJlcG9ydCh7XG4gICAgICAgICAgICAgICAgbm9kZTogcHJvcGVydHksXG4gICAgICAgICAgICAgICAgbWVzc2FnZTogJ09ubHkgZGVzdHJ1Y3R1cmUgdG9wLWxldmVsIG5hbWVzLicsXG4gICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKCFuYW1lc3BhY2UuaGFzKHByb3BlcnR5LmtleS5uYW1lKSkge1xuICAgICAgICAgICAgICBjb250ZXh0LnJlcG9ydCh7XG4gICAgICAgICAgICAgICAgbm9kZTogcHJvcGVydHksXG4gICAgICAgICAgICAgICAgbWVzc2FnZTogbWFrZU1lc3NhZ2UocHJvcGVydHkua2V5LCBwYXRoKSxcbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBwYXRoLnB1c2gocHJvcGVydHkua2V5Lm5hbWUpO1xuICAgICAgICAgICAgY29uc3QgZGVwZW5kZW5jeUV4cG9ydE1hcCA9IG5hbWVzcGFjZS5nZXQocHJvcGVydHkua2V5Lm5hbWUpO1xuICAgICAgICAgICAgLy8gY291bGQgYmUgbnVsbCB3aGVuIGlnbm9yZWQgb3IgYW1iaWd1b3VzXG4gICAgICAgICAgICBpZiAoZGVwZW5kZW5jeUV4cG9ydE1hcCAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICB0ZXN0S2V5KHByb3BlcnR5LnZhbHVlLCBkZXBlbmRlbmN5RXhwb3J0TWFwLm5hbWVzcGFjZSwgcGF0aCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBwYXRoLnBvcCgpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHRlc3RLZXkoaWQsIG5hbWVzcGFjZXMuZ2V0KGluaXQubmFtZSkpO1xuICAgICAgfSxcblxuICAgICAgSlNYTWVtYmVyRXhwcmVzc2lvbih7IG9iamVjdCwgcHJvcGVydHkgfSkge1xuICAgICAgICBpZiAoIW5hbWVzcGFjZXMuaGFzKG9iamVjdC5uYW1lKSkgcmV0dXJuO1xuICAgICAgICBjb25zdCBuYW1lc3BhY2UgPSBuYW1lc3BhY2VzLmdldChvYmplY3QubmFtZSk7XG4gICAgICAgIGlmICghbmFtZXNwYWNlLmhhcyhwcm9wZXJ0eS5uYW1lKSkge1xuICAgICAgICAgIGNvbnRleHQucmVwb3J0KHtcbiAgICAgICAgICAgIG5vZGU6IHByb3BlcnR5LFxuICAgICAgICAgICAgbWVzc2FnZTogbWFrZU1lc3NhZ2UocHJvcGVydHksIFtvYmplY3QubmFtZV0pLFxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9LFxuICAgIH07XG4gIH0sXG59O1xuIl19
|