mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
153 lines
15 KiB
JavaScript
153 lines
15 KiB
JavaScript
'use strict';var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);
|
|
var _object = require('object.values');var _object2 = _interopRequireDefault(_object);
|
|
var _arrayPrototype = require('array.prototype.flat');var _arrayPrototype2 = _interopRequireDefault(_arrayPrototype);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
|
|
|
|
var meta = {
|
|
type: 'suggestion',
|
|
docs: {
|
|
url: (0, _docsUrl2['default'])('group-exports') } };
|
|
|
|
|
|
/* eslint-disable max-len */
|
|
var errors = {
|
|
ExportNamedDeclaration: 'Multiple named export declarations; consolidate all named exports into a single export declaration',
|
|
AssignmentExpression: 'Multiple CommonJS exports; consolidate all exports into a single assignment to `module.exports`' };
|
|
|
|
/* eslint-enable max-len */
|
|
|
|
/**
|
|
* Returns an array with names of the properties in the accessor chain for MemberExpression nodes
|
|
*
|
|
* Example:
|
|
*
|
|
* `module.exports = {}` => ['module', 'exports']
|
|
* `module.exports.property = true` => ['module', 'exports', 'property']
|
|
*
|
|
* @param {Node} node AST Node (MemberExpression)
|
|
* @return {Array} Array with the property names in the chain
|
|
* @private
|
|
*/
|
|
function accessorChain(node) {
|
|
var chain = [];
|
|
|
|
do {
|
|
chain.unshift(node.property.name);
|
|
|
|
if (node.object.type === 'Identifier') {
|
|
chain.unshift(node.object.name);
|
|
break;
|
|
}
|
|
|
|
node = node.object;
|
|
} while (node.type === 'MemberExpression');
|
|
|
|
return chain;
|
|
}
|
|
|
|
function create(context) {
|
|
var nodes = {
|
|
modules: {
|
|
set: new Set(),
|
|
sources: {} },
|
|
|
|
types: {
|
|
set: new Set(),
|
|
sources: {} },
|
|
|
|
commonjs: {
|
|
set: new Set() } };
|
|
|
|
|
|
|
|
return {
|
|
ExportNamedDeclaration: function () {function ExportNamedDeclaration(node) {
|
|
var target = node.exportKind === 'type' ? nodes.types : nodes.modules;
|
|
if (!node.source) {
|
|
target.set.add(node);
|
|
} else if (Array.isArray(target.sources[node.source.value])) {
|
|
target.sources[node.source.value].push(node);
|
|
} else {
|
|
target.sources[node.source.value] = [node];
|
|
}
|
|
}return ExportNamedDeclaration;}(),
|
|
|
|
AssignmentExpression: function () {function AssignmentExpression(node) {
|
|
if (node.left.type !== 'MemberExpression') {
|
|
return;
|
|
}
|
|
|
|
var chain = accessorChain(node.left);
|
|
|
|
// Assignments to module.exports
|
|
// Deeper assignments are ignored since they just modify what's already being exported
|
|
// (ie. module.exports.exported.prop = true is ignored)
|
|
if (chain[0] === 'module' && chain[1] === 'exports' && chain.length <= 3) {
|
|
nodes.commonjs.set.add(node);
|
|
return;
|
|
}
|
|
|
|
// Assignments to exports (exports.* = *)
|
|
if (chain[0] === 'exports' && chain.length === 2) {
|
|
nodes.commonjs.set.add(node);
|
|
return;
|
|
}
|
|
}return AssignmentExpression;}(),
|
|
|
|
'Program:exit': function () {function onExit() {
|
|
// Report multiple `export` declarations (ES2015 modules)
|
|
if (nodes.modules.set.size > 1) {
|
|
nodes.modules.set.forEach(function (node) {
|
|
context.report({
|
|
node: node,
|
|
message: errors[node.type] });
|
|
|
|
});
|
|
}
|
|
|
|
// Report multiple `aggregated exports` from the same module (ES2015 modules)
|
|
(0, _arrayPrototype2['default'])((0, _object2['default'])(nodes.modules.sources).
|
|
filter(function (nodesWithSource) {return Array.isArray(nodesWithSource) && nodesWithSource.length > 1;})).
|
|
forEach(function (node) {
|
|
context.report({
|
|
node: node,
|
|
message: errors[node.type] });
|
|
|
|
});
|
|
|
|
// Report multiple `export type` declarations (FLOW ES2015 modules)
|
|
if (nodes.types.set.size > 1) {
|
|
nodes.types.set.forEach(function (node) {
|
|
context.report({
|
|
node: node,
|
|
message: errors[node.type] });
|
|
|
|
});
|
|
}
|
|
|
|
// Report multiple `aggregated type exports` from the same module (FLOW ES2015 modules)
|
|
(0, _arrayPrototype2['default'])((0, _object2['default'])(nodes.types.sources).
|
|
filter(function (nodesWithSource) {return Array.isArray(nodesWithSource) && nodesWithSource.length > 1;})).
|
|
forEach(function (node) {
|
|
context.report({
|
|
node: node,
|
|
message: errors[node.type] });
|
|
|
|
});
|
|
|
|
// Report multiple `module.exports` assignments (CommonJS)
|
|
if (nodes.commonjs.set.size > 1) {
|
|
nodes.commonjs.set.forEach(function (node) {
|
|
context.report({
|
|
node: node,
|
|
message: errors[node.type] });
|
|
|
|
});
|
|
}
|
|
}return onExit;}() };
|
|
|
|
}
|
|
|
|
module.exports = {
|
|
meta: meta,
|
|
create: create };
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9ncm91cC1leHBvcnRzLmpzIl0sIm5hbWVzIjpbIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsImVycm9ycyIsIkV4cG9ydE5hbWVkRGVjbGFyYXRpb24iLCJBc3NpZ25tZW50RXhwcmVzc2lvbiIsImFjY2Vzc29yQ2hhaW4iLCJub2RlIiwiY2hhaW4iLCJ1bnNoaWZ0IiwicHJvcGVydHkiLCJuYW1lIiwib2JqZWN0IiwiY3JlYXRlIiwiY29udGV4dCIsIm5vZGVzIiwibW9kdWxlcyIsInNldCIsIlNldCIsInNvdXJjZXMiLCJ0eXBlcyIsImNvbW1vbmpzIiwidGFyZ2V0IiwiZXhwb3J0S2luZCIsInNvdXJjZSIsImFkZCIsIkFycmF5IiwiaXNBcnJheSIsInZhbHVlIiwicHVzaCIsImxlZnQiLCJsZW5ndGgiLCJvbkV4aXQiLCJzaXplIiwiZm9yRWFjaCIsInJlcG9ydCIsIm1lc3NhZ2UiLCJmaWx0ZXIiLCJub2Rlc1dpdGhTb3VyY2UiLCJtb2R1bGUiLCJleHBvcnRzIl0sIm1hcHBpbmdzIjoiYUFBQSxxQztBQUNBLHVDO0FBQ0Esc0Q7O0FBRUEsSUFBTUEsT0FBTztB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G9ydCh7XG4gICAgICAgICAgICBub2RlLFxuICAgICAgICAgICAgbWVzc2FnZTogZXJyb3JzW25vZGUudHlwZV0sXG4gICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgICAgfVxuXG4gICAgICAvLyBSZXBvcnQgbXVsdGlwbGUgYGFnZ3JlZ2F0ZWQgdHlwZSBleHBvcnRzYCBmcm9tIHRoZSBzYW1lIG1vZHVsZSAoRkxPVyBFUzIwMTUgbW9kdWxlcylcbiAgICAgIGZsYXQodmFsdWVzKG5vZGVzLnR5cGVzLnNvdXJjZXMpXG4gICAgICAgIC5maWx0ZXIobm9kZXNXaXRoU291cmNlID0+IEFycmF5LmlzQXJyYXkobm9kZXNXaXRoU291cmNlKSAmJiBub2Rlc1dpdGhTb3VyY2UubGVuZ3RoID4gMSkpXG4gICAgICAgIC5mb3JFYWNoKChub2RlKSA9PiB7XG4gICAgICAgICAgY29udGV4dC5yZXBvcnQoe1xuICAgICAgICAgICAgbm9kZSxcbiAgICAgICAgICAgIG1lc3NhZ2U6IGVycm9yc1tub2RlLnR5cGVdLFxuICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcblxuICAgICAgLy8gUmVwb3J0IG11bHRpcGxlIGBtb2R1bGUuZXhwb3J0c2AgYXNzaWdubWVudHMgKENvbW1vbkpTKVxuICAgICAgaWYgKG5vZGVzLmNvbW1vbmpzLnNldC5zaXplID4gMSkge1xuICAgICAgICBub2Rlcy5jb21tb25qcy5zZXQuZm9yRWFjaChub2RlID0+IHtcbiAgICAgICAgICBjb250ZXh0LnJlcG9ydCh7XG4gICAgICAgICAgICBub2RlLFxuICAgICAgICAgICAgbWVzc2FnZTogZXJyb3JzW25vZGUudHlwZV0sXG4gICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgIH0sXG4gIH07XG59XG5cbm1vZHVsZS5leHBvcnRzID0ge1xuICBtZXRhLFxuICBjcmVhdGUsXG59O1xuIl19
|