odin-js-fundamentals-part-4/node_modules/eslint-plugin-import/lib/rules/export.js

250 lines
32 KiB
JavaScript

'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _ExportMap = require('../ExportMap');var _ExportMap2 = _interopRequireDefault(_ExportMap);
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);
var _arrayIncludes = require('array-includes');var _arrayIncludes2 = _interopRequireDefault(_arrayIncludes);
var _arrayPrototype = require('array.prototype.flatmap');var _arrayPrototype2 = _interopRequireDefault(_arrayPrototype);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
/*
Notes on TypeScript namespaces aka TSModuleDeclaration:
There are two forms:
- active namespaces: namespace Foo {} / module Foo {}
- ambient modules; declare module "eslint-plugin-import" {}
active namespaces:
- cannot contain a default export
- cannot contain an export all
- cannot contain a multi name export (export { a, b })
- can have active namespaces nested within them
ambient namespaces:
- can only be defined in .d.ts files
- cannot be nested within active namespaces
- have no other restrictions
*/
var rootProgram = 'root';
var tsTypePrefix = 'type:';
/**
* Detect function overloads like:
* ```ts
* export function foo(a: number);
* export function foo(a: string);
* export function foo(a: number|string) { return a; }
* ```
* @param {Set<Object>} nodes
* @returns {boolean}
*/
function isTypescriptFunctionOverloads(nodes) {
var nodesArr = Array.from(nodes);
var idents = (0, _arrayPrototype2['default'])(
nodesArr,
function (node) {return node.declaration && (
node.declaration.type === 'TSDeclareFunction' // eslint 6+
|| node.declaration.type === 'TSEmptyBodyFunctionDeclaration' // eslint 4-5
) ?
node.declaration.id.name :
[];});
if (new Set(idents).size !== idents.length) {
return true;
}
var types = new Set(nodesArr.map(function (node) {return node.parent.type;}));
if (!types.has('TSDeclareFunction')) {
return false;
}
if (types.size === 1) {
return true;
}
if (types.size === 2 && types.has('FunctionDeclaration')) {
return true;
}
return false;
}
/**
* Detect merging Namespaces with Classes, Functions, or Enums like:
* ```ts
* export class Foo { }
* export namespace Foo { }
* ```
* @param {Set<Object>} nodes
* @returns {boolean}
*/
function isTypescriptNamespaceMerging(nodes) {
var types = new Set(Array.from(nodes, function (node) {return node.parent.type;}));
var noNamespaceNodes = Array.from(nodes).filter(function (node) {return node.parent.type !== 'TSModuleDeclaration';});
return types.has('TSModuleDeclaration') && (
types.size === 1
// Merging with functions
|| types.size === 2 && (types.has('FunctionDeclaration') || types.has('TSDeclareFunction')) ||
types.size === 3 && types.has('FunctionDeclaration') && types.has('TSDeclareFunction')
// Merging with classes or enums
|| types.size === 2 && (types.has('ClassDeclaration') || types.has('TSEnumDeclaration')) && noNamespaceNodes.length === 1);
}
/**
* Detect if a typescript namespace node should be reported as multiple export:
* ```ts
* export class Foo { }
* export function Foo();
* export namespace Foo { }
* ```
* @param {Object} node
* @param {Set<Object>} nodes
* @returns {boolean}
*/
function shouldSkipTypescriptNamespace(node, nodes) {
var types = new Set(Array.from(nodes, function (node) {return node.parent.type;}));
return !isTypescriptNamespaceMerging(nodes) &&
node.parent.type === 'TSModuleDeclaration' && (
types.has('TSEnumDeclaration') ||
types.has('ClassDeclaration') ||
types.has('FunctionDeclaration') ||
types.has('TSDeclareFunction'));
}
module.exports = {
meta: {
type: 'problem',
docs: {
category: 'Helpful warnings',
description: 'Forbid any invalid exports, i.e. re-export of the same name.',
url: (0, _docsUrl2['default'])('export') },
schema: [] },
create: function () {function create(context) {
var namespace = new Map([[rootProgram, new Map()]]);
function addNamed(name, node, parent, isType) {
if (!namespace.has(parent)) {
namespace.set(parent, new Map());
}
var named = namespace.get(parent);
var key = isType ? '' + tsTypePrefix + String(name) : name;
var nodes = named.get(key);
if (nodes == null) {
nodes = new Set();
named.set(key, nodes);
}
nodes.add(node);
}
function getParent(node) {
if (node.parent && node.parent.type === 'TSModuleBlock') {
return node.parent.parent;
}
// just in case somehow a non-ts namespace export declaration isn't directly
// parented to the root Program node
return rootProgram;
}
return {
ExportDefaultDeclaration: function () {function ExportDefaultDeclaration(node) {
addNamed('default', node, getParent(node));
}return ExportDefaultDeclaration;}(),
ExportSpecifier: function () {function ExportSpecifier(node) {
addNamed(
node.exported.name || node.exported.value,
node.exported,
getParent(node.parent));
}return ExportSpecifier;}(),
ExportNamedDeclaration: function () {function ExportNamedDeclaration(node) {
if (node.declaration == null) {return;}
var parent = getParent(node);
// support for old TypeScript versions
var isTypeVariableDecl = node.declaration.kind === 'type';
if (node.declaration.id != null) {
if ((0, _arrayIncludes2['default'])([
'TSTypeAliasDeclaration',
'TSInterfaceDeclaration'],
node.declaration.type)) {
addNamed(node.declaration.id.name, node.declaration.id, parent, true);
} else {
addNamed(node.declaration.id.name, node.declaration.id, parent, isTypeVariableDecl);
}
}
if (node.declaration.declarations != null) {var _iteratorNormalCompletion = true;var _didIteratorError = false;var _iteratorError = undefined;try {
for (var _iterator = node.declaration.declarations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {var declaration = _step.value;
(0, _ExportMap.recursivePatternCapture)(declaration.id, function (v) {addNamed(v.name, v, parent, isTypeVariableDecl);});
}} catch (err) {_didIteratorError = true;_iteratorError = err;} finally {try {if (!_iteratorNormalCompletion && _iterator['return']) {_iterator['return']();}} finally {if (_didIteratorError) {throw _iteratorError;}}}
}
}return ExportNamedDeclaration;}(),
ExportAllDeclaration: function () {function ExportAllDeclaration(node) {
if (node.source == null) {return;} // not sure if this is ever true
// `export * as X from 'path'` does not conflict
if (node.exported && node.exported.name) {return;}
var remoteExports = _ExportMap2['default'].get(node.source.value, context);
if (remoteExports == null) {return;}
if (remoteExports.errors.length) {
remoteExports.reportErrors(context, node);
return;
}
var parent = getParent(node);
var any = false;
remoteExports.forEach(function (v, name) {
if (name !== 'default') {
any = true; // poor man's filter
addNamed(name, node, parent);
}
});
if (!any) {
context.report(
node.source, 'No named exports found in module \'' + String(
node.source.value) + '\'.');
}
}return ExportAllDeclaration;}(),
'Program:exit': function () {function ProgramExit() {var _iteratorNormalCompletion2 = true;var _didIteratorError2 = false;var _iteratorError2 = undefined;try {
for (var _iterator2 = namespace[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {var _ref = _step2.value;var _ref2 = _slicedToArray(_ref, 2);var named = _ref2[1];var _iteratorNormalCompletion3 = true;var _didIteratorError3 = false;var _iteratorError3 = undefined;try {
for (var _iterator3 = named[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {var _ref3 = _step3.value;var _ref4 = _slicedToArray(_ref3, 2);var name = _ref4[0];var nodes = _ref4[1];
if (nodes.size <= 1) {continue;}
if (isTypescriptFunctionOverloads(nodes) || isTypescriptNamespaceMerging(nodes)) {continue;}var _iteratorNormalCompletion4 = true;var _didIteratorError4 = false;var _iteratorError4 = undefined;try {
for (var _iterator4 = nodes[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {var node = _step4.value;
if (shouldSkipTypescriptNamespace(node, nodes)) {continue;}
if (name === 'default') {
context.report(node, 'Multiple default exports.');
} else {
context.report(
node, 'Multiple exports of name \'' + String(
name.replace(tsTypePrefix, '')) + '\'.');
}
}} catch (err) {_didIteratorError4 = true;_iteratorError4 = err;} finally {try {if (!_iteratorNormalCompletion4 && _iterator4['return']) {_iterator4['return']();}} finally {if (_didIteratorError4) {throw _iteratorError4;}}}
}} catch (err) {_didIteratorError3 = true;_iteratorError3 = err;} finally {try {if (!_iteratorNormalCompletion3 && _iterator3['return']) {_iterator3['return']();}} finally {if (_didIteratorError3) {throw _iteratorError3;}}}
}} catch (err) {_didIteratorError2 = true;_iteratorError2 = err;} finally {try {if (!_iteratorNormalCompletion2 && _iterator2['return']) {_iterator2['return']();}} finally {if (_didIteratorError2) {throw _iteratorError2;}}}
}return ProgramExit;}() };
}return create;}() };
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9leHBvcnQuanMiXSwibmFtZXMiOlsicm9vdFByb2dyYW0iLCJ0c1R5cGVQcmVmaXgiLCJpc1R5cGVzY3JpcHRGdW5jdGlvbk92ZXJsb2FkcyIsIm5vZGVzIiwibm9kZXNBcnIiLCJBcnJheSIsImZyb20iLCJpZGVudHMiLCJub2RlIiwiZGVjbGFyYXRpb24iLCJ0eXBlIiwiaWQiLCJuYW1lIiwiU2V0Iiwic2l6ZSIsImxlbmd0aCIsInR5cGVzIiwibWFwIiwicGFyZW50IiwiaGFzIiwiaXNUeXBlc2NyaXB0TmFtZXNwYWNlTWVyZ2luZyIsIm5vTmFtZXNwYWNlTm9kZXMiLCJmaWx0ZXIiLCJzaG91bGRTa2lwVHlwZXNjcmlwdE5hbWVzcGFjZSIsIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwiZG9jcyIsImNhdGVnb3J5IiwiZGVzY3JpcHRpb24iLCJ1cmwiLCJzY2hlbWEiLCJjcmVhdGUiLCJjb250ZXh0IiwibmFtZXNwYWNlIiwiTWFwIiwiYWRkTmFtZWQiLCJpc1R5cGUiLCJzZXQiLCJuYW1lZCIsImdldCIsImtleSIsImFkZCIsImdldFBhcmVudCIsIkV4cG9ydERlZmF1bHREZWNsYXJhdGlvbiIsIkV4cG9ydFNwZWNpZmllciIsImV4cG9ydGVkIiwidmFsdWUiLCJFeHBvcnROYW1lZERlY2xhcmF0aW9uIiwiaXNUeXBlVmFyaWFibGVEZWNsIiwia2luZC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ICAgICAgY29udGV4dC5yZXBvcnQoXG4gICAgICAgICAgICBub2RlLnNvdXJjZSxcbiAgICAgICAgICAgIGBObyBuYW1lZCBleHBvcnRzIGZvdW5kIGluIG1vZHVsZSAnJHtub2RlLnNvdXJjZS52YWx1ZX0nLmAsXG4gICAgICAgICAgKTtcbiAgICAgICAgfVxuICAgICAgfSxcblxuICAgICAgJ1Byb2dyYW06ZXhpdCcoKSB7XG4gICAgICAgIGZvciAoY29uc3QgWywgbmFtZWRdIG9mIG5hbWVzcGFjZSkge1xuICAgICAgICAgIGZvciAoY29uc3QgW25hbWUsIG5vZGVzXSBvZiBuYW1lZCkge1xuICAgICAgICAgICAgaWYgKG5vZGVzLnNpemUgPD0gMSkgeyBjb250aW51ZTsgfVxuXG4gICAgICAgICAgICBpZiAoaXNUeXBlc2NyaXB0RnVuY3Rpb25PdmVybG9hZHMobm9kZXMpIHx8IGlzVHlwZXNjcmlwdE5hbWVzcGFjZU1lcmdpbmcobm9kZXMpKSB7IGNvbnRpbnVlOyB9XG5cbiAgICAgICAgICAgIGZvciAoY29uc3Qgbm9kZSBvZiBub2Rlcykge1xuICAgICAgICAgICAgICBpZiAoc2hvdWxkU2tpcFR5cGVzY3JpcHROYW1lc3BhY2Uobm9kZSwgbm9kZXMpKSB7IGNvbnRpbnVlOyB9XG5cbiAgICAgICAgICAgICAgaWYgKG5hbWUgPT09ICdkZWZhdWx0Jykge1xuICAgICAgICAgICAgICAgIGNvbnRleHQucmVwb3J0KG5vZGUsICdNdWx0aXBsZSBkZWZhdWx0IGV4cG9ydHMuJyk7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29udGV4dC5yZXBvcnQoXG4gICAgICAgICAgICAgICAgICBub2RlLFxuICAgICAgICAgICAgICAgICAgYE11bHRpcGxlIGV4cG9ydHMgb2YgbmFtZSAnJHtuYW1lLnJlcGxhY2UodHNUeXBlUHJlZml4LCAnJyl9Jy5gLFxuICAgICAgICAgICAgICAgICk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgfTtcbiAgfSxcbn07XG4iXX0=