1087 lines
125 KiB
JavaScript
1087 lines
125 KiB
JavaScript
|
'use strict';var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {return typeof obj;} : function (obj) {return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;};
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
var _ignore = require('eslint-module-utils/ignore');
|
||
|
var _resolve = require('eslint-module-utils/resolve');var _resolve2 = _interopRequireDefault(_resolve);
|
||
|
var _visit = require('eslint-module-utils/visit');var _visit2 = _interopRequireDefault(_visit);
|
||
|
var _path = require('path');
|
||
|
var _readPkgUp2 = require('eslint-module-utils/readPkgUp');var _readPkgUp3 = _interopRequireDefault(_readPkgUp2);
|
||
|
var _object = require('object.values');var _object2 = _interopRequireDefault(_object);
|
||
|
var _arrayIncludes = require('array-includes');var _arrayIncludes2 = _interopRequireDefault(_arrayIncludes);
|
||
|
var _arrayPrototype = require('array.prototype.flatmap');var _arrayPrototype2 = _interopRequireDefault(_arrayPrototype);
|
||
|
|
||
|
var _fsWalk = require('../core/fsWalk');
|
||
|
var _builder = require('../exportMap/builder');var _builder2 = _interopRequireDefault(_builder);
|
||
|
var _patternCapture = require('../exportMap/patternCapture');var _patternCapture2 = _interopRequireDefault(_patternCapture);
|
||
|
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}function _toConsumableArray(arr) {if (Array.isArray(arr)) {for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {arr2[i] = arr[i];}return arr2;} else {return Array.from(arr);}} /**
|
||
|
* @fileOverview Ensures that modules contain exports and/or all
|
||
|
* modules are consumed within other modules.
|
||
|
* @author René Fermann
|
||
|
*/ /**
|
||
|
* Attempt to load the internal `FileEnumerator` class, which has existed in a couple
|
||
|
* of different places, depending on the version of `eslint`. Try requiring it from both
|
||
|
* locations.
|
||
|
* @returns Returns the `FileEnumerator` class if its requirable, otherwise `undefined`.
|
||
|
*/function requireFileEnumerator() {var FileEnumerator = void 0;
|
||
|
|
||
|
// Try getting it from the eslint private / deprecated api
|
||
|
try {var _require =
|
||
|
require('eslint/use-at-your-own-risk');FileEnumerator = _require.FileEnumerator;
|
||
|
} catch (e) {
|
||
|
// Absorb this if it's MODULE_NOT_FOUND
|
||
|
if (e.code !== 'MODULE_NOT_FOUND') {
|
||
|
throw e;
|
||
|
}
|
||
|
|
||
|
// If not there, then try getting it from eslint/lib/cli-engine/file-enumerator (moved there in v6)
|
||
|
try {var _require2 =
|
||
|
require('eslint/lib/cli-engine/file-enumerator');FileEnumerator = _require2.FileEnumerator;
|
||
|
} catch (e) {
|
||
|
// Absorb this if it's MODULE_NOT_FOUND
|
||
|
if (e.code !== 'MODULE_NOT_FOUND') {
|
||
|
throw e;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return FileEnumerator;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @param FileEnumerator the `FileEnumerator` class from `eslint`'s internal api
|
||
|
* @param {string} src path to the src root
|
||
|
* @param {string[]} extensions list of supported extensions
|
||
|
* @returns {{ filename: string, ignored: boolean }[]} list of files to operate on
|
||
|
*/
|
||
|
function listFilesUsingFileEnumerator(FileEnumerator, src, extensions) {
|
||
|
var e = new FileEnumerator({
|
||
|
extensions: extensions });
|
||
|
|
||
|
|
||
|
return Array.from(
|
||
|
e.iterateFiles(src),
|
||
|
function (_ref) {var filePath = _ref.filePath,ignored = _ref.ignored;return { filename: filePath, ignored: ignored };});
|
||
|
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Attempt to require old versions of the file enumeration capability from v6 `eslint` and earlier, and use
|
||
|
* those functions to provide the list of files to operate on
|
||
|
* @param {string} src path to the src root
|
||
|
* @param {string[]} extensions list of supported extensions
|
||
|
* @returns {string[]} list of files to operate on
|
||
|
*/
|
||
|
function listFilesWithLegacyFunctions(src, extensions) {
|
||
|
try {
|
||
|
// eslint/lib/util/glob-util has been moved to eslint/lib/util/glob-utils with version 5.3
|
||
|
var _require3 = require('eslint/lib/util/glob-utils'),originalListFilesToProcess = _require3.listFilesToProcess;
|
||
|
// Prevent passing invalid options (extensions array) to old versions of the function.
|
||
|
// https://github.com/eslint/eslint/blob/v5.16.0/lib/util/glob-utils.js#L178-L280
|
||
|
// https://github.com/eslint/eslint/blob/v5.2.0/lib/util/glob-util.js#L174-L269
|
||
|
|
||
|
return originalListFilesToProcess(src, {
|
||
|
extensions: extensions });
|
||
|
|
||
|
} catch (e) {
|
||
|
// Absorb this if it's MODULE_NOT_FOUND
|
||
|
if (e.code !== 'MODULE_NOT_FOUND') {
|
||
|
throw e;
|
||
|
}
|
||
|
|
||
|
// Last place to try (pre v5.3)
|
||
|
var _require4 =
|
||
|
|
||
|
require('eslint/lib/util/glob-util'),_originalListFilesToProcess = _require4.listFilesToProcess;
|
||
|
var patterns = src.concat(
|
||
|
(0, _arrayPrototype2['default'])(
|
||
|
src,
|
||
|
function (pattern) {return extensions.map(function (extension) {return (/\*\*|\*\./.test(pattern) ? pattern : String(pattern) + '/**/*' + String(extension));});}));
|
||
|
|
||
|
|
||
|
|
||
|
return _originalListFilesToProcess(patterns);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Given a source root and list of supported extensions, use fsWalk and the
|
||
|
* new `eslint` `context.session` api to build the list of files we want to operate on
|
||
|
* @param {string[]} srcPaths array of source paths (for flat config this should just be a singular root (e.g. cwd))
|
||
|
* @param {string[]} extensions list of supported extensions
|
||
|
* @param {{ isDirectoryIgnored: (path: string) => boolean, isFileIgnored: (path: string) => boolean }} session eslint context session object
|
||
|
* @returns {string[]} list of files to operate on
|
||
|
*/
|
||
|
function listFilesWithModernApi(srcPaths, extensions, session) {
|
||
|
/** @type {string[]} */
|
||
|
var files = [];var _loop = function _loop(
|
||
|
|
||
|
i) {
|
||
|
var src = srcPaths[i];
|
||
|
// Use walkSync along with the new session api to gather the list of files
|
||
|
var entries = (0, _fsWalk.walkSync)(src, {
|
||
|
deepFilter: function () {function deepFilter(entry) {
|
||
|
var fullEntryPath = (0, _path.resolve)(src, entry.path);
|
||
|
|
||
|
// Include the directory if it's not marked as ignore by eslint
|
||
|
return !session.isDirectoryIgnored(fullEntryPath);
|
||
|
}return deepFilter;}(),
|
||
|
entryFilter: function () {function entryFilter(entry) {
|
||
|
var fullEntryPath = (0, _path.resolve)(src, entry.path);
|
||
|
|
||
|
// Include the file if it's not marked as ignore by eslint and its extension is included in our list
|
||
|
return (
|
||
|
!session.isFileIgnored(fullEntryPath) &&
|
||
|
extensions.find(function (extension) {return entry.path.endsWith(extension);}));
|
||
|
|
||
|
}return entryFilter;}() });
|
||
|
|
||
|
|
||
|
// Filter out directories and map entries to their paths
|
||
|
files.push.apply(files, _toConsumableArray(
|
||
|
entries.
|
||
|
filter(function (entry) {return !entry.dirent.isDirectory();}).
|
||
|
map(function (entry) {return entry.path;})));};for (var i = 0; i < srcPaths.length; i++) {_loop(i);
|
||
|
|
||
|
}
|
||
|
return files;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Given a src pattern and list of supported extensions, return a list of files to process
|
||
|
* with this rule.
|
||
|
* @param {string} src - file, directory, or glob pattern of files to act on
|
||
|
* @param {string[]} extensions - list of supported file extensions
|
||
|
* @param {import('eslint').Rule.RuleContext} context - the eslint context object
|
||
|
* @returns {string[] | { filename: string, ignored: boolean }[]} the list of files that this rule will evaluate.
|
||
|
*/
|
||
|
function listFilesToProcess(src, extensions, context) {
|
||
|
// If the context object has the new session functions, then prefer those
|
||
|
// Otherwise, fallback to using the deprecated `FileEnumerator` for legacy support.
|
||
|
// https://github.com/eslint/eslint/issues/18087
|
||
|
if (
|
||
|
context.session &&
|
||
|
context.session.isFileIgnored &&
|
||
|
context.session.isDirectoryIgnored)
|
||
|
{
|
||
|
return listFilesWithModernApi(src, extensions, context.session);
|
||
|
}
|
||
|
|
||
|
// Fallback to og FileEnumerator
|
||
|
var FileEnumerator = requireFileEnumerator();
|
||
|
|
||
|
// If we got the FileEnumerator, then let's go with that
|
||
|
if (FileEnumerator) {
|
||
|
return listFilesUsingFileEnumerator(FileEnumerator, src, extensions);
|
||
|
}
|
||
|
// If not, then we can try even older versions of this capability (listFilesToProcess)
|
||
|
return listFilesWithLegacyFunctions(src, extensions);
|
||
|
}
|
||
|
|
||
|
var EXPORT_DEFAULT_DECLARATION = 'ExportDefaultDeclaration';
|
||
|
var EXPORT_NAMED_DECLARATION = 'ExportNamedDeclaration';
|
||
|
var EXPORT_ALL_DECLARATION = 'ExportAllDeclaration';
|
||
|
var IMPORT_DECLARATION = 'ImportDeclaration';
|
||
|
var IMPORT_NAMESPACE_SPECIFIER = 'ImportNamespaceSpecifier';
|
||
|
var IMPORT_DEFAULT_SPECIFIER = 'ImportDefaultSpecifier';
|
||
|
var VARIABLE_DECLARATION = 'VariableDeclaration';
|
||
|
var FUNCTION_DECLARATION = 'FunctionDeclaration';
|
||
|
var CLASS_DECLARATION = 'ClassDeclaration';
|
||
|
var IDENTIFIER = 'Identifier';
|
||
|
var OBJECT_PATTERN = 'ObjectPattern';
|
||
|
var ARRAY_PATTERN = 'ArrayPattern';
|
||
|
var TS_INTERFACE_DECLARATION = 'TSInterfaceDeclaration';
|
||
|
var TS_TYPE_ALIAS_DECLARATION = 'TSTypeAliasDeclaration';
|
||
|
var TS_ENUM_DECLARATION = 'TSEnumDeclaration';
|
||
|
var DEFAULT = 'default';
|
||
|
|
||
|
function forEachDeclarationIdentifier(declaration, cb) {
|
||
|
if (declaration) {
|
||
|
var isTypeDeclaration = declaration.type === TS_INTERFACE_DECLARATION ||
|
||
|
declaration.type === TS_TYPE_ALIAS_DECLARATION ||
|
||
|
declaration.type === TS_ENUM_DECLARATION;
|
||
|
|
||
|
if (
|
||
|
declaration.type === FUNCTION_DECLARATION ||
|
||
|
declaration.type === CLASS_DECLARATION ||
|
||
|
isTypeDeclaration)
|
||
|
{
|
||
|
cb(declaration.id.name, isTypeDeclaration);
|
||
|
} else if (declaration.type === VARIABLE_DECLARATION) {
|
||
|
declaration.declarations.forEach(function (_ref2) {var id = _ref2.id;
|
||
|
if (id.type === OBJECT_PATTERN) {
|
||
|
(0, _patternCapture2['default'])(id, function (pattern) {
|
||
|
if (pattern.type === IDENTIFIER) {
|
||
|
cb(pattern.name, false);
|
||
|
}
|
||
|
});
|
||
|
} else if (id.type === ARRAY_PATTERN) {
|
||
|
id.elements.forEach(function (_ref3) {var name = _ref3.name;
|
||
|
cb(name, false);
|
||
|
});
|
||
|
} else {
|
||
|
cb(id.name, false);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* List of imports per file.
|
||
|
*
|
||
|
* Represented by a two-level Map to a Set of identifiers. The upper-level Map
|
||
|
* keys are the paths to the modules containing the imports, while the
|
||
|
* lower-level Map keys are the paths to the files which are being imported
|
||
|
* from. Lastly, the Set of identifiers contains either names being imported
|
||
|
* or a special AST node name listed above (e.g ImportDefaultSpecifier).
|
||
|
*
|
||
|
* For example, if we have a file named foo.js containing:
|
||
|
*
|
||
|
* import { o2 } from './bar.js';
|
||
|
*
|
||
|
* Then we will have a structure that looks like:
|
||
|
*
|
||
|
* Map { 'foo.js' => Map { 'bar.js' => Set { 'o2' } } }
|
||
|
*
|
||
|
* @type {Map<string, Map<string, Set<string>>>}
|
||
|
*/
|
||
|
var importList = new Map();
|
||
|
|
||
|
/**
|
||
|
* List of exports per file.
|
||
|
*
|
||
|
* Represented by a two-level Map to an object of metadata. The upper-level Map
|
||
|
* keys are the paths to the modules containing the exports, while the
|
||
|
* lower-level Map keys are the specific identifiers or special AST node names
|
||
|
* being exported. The leaf-level metadata object at the moment only contains a
|
||
|
* `whereUsed` property, which contains a Set of paths to modules that import
|
||
|
* the name.
|
||
|
*
|
||
|
* For example, if we have a file named bar.js containing the following exports:
|
||
|
*
|
||
|
* const o2 = 'bar';
|
||
|
* export { o2 };
|
||
|
*
|
||
|
* And a file named foo.js containing the following import:
|
||
|
*
|
||
|
* import { o2 } from './bar.js';
|
||
|
*
|
||
|
* Then we will have a structure that looks like:
|
||
|
*
|
||
|
* Map { 'bar.js' => Map { 'o2' => { whereUsed: Set { 'foo.js' } } } }
|
||
|
*
|
||
|
* @type {Map<string, Map<string, object>>}
|
||
|
*/
|
||
|
var exportList = new Map();
|
||
|
|
||
|
var visitorKeyMap = new Map();
|
||
|
|
||
|
/** @type {Set<string>} */
|
||
|
var ignoredFiles = new Set();
|
||
|
var filesOutsideSrc = new Set();
|
||
|
|
||
|
var isNodeModule = function isNodeModule(path) {return (/\/(node_modules)\//.test(path));};
|
||
|
|
||
|
/**
|
||
|
* read all files matching the patterns in src and ignoreExports
|
||
|
*
|
||
|
* return all files matching src pattern, which are not matching the ignoreExports pattern
|
||
|
* @type {(src: string, ignoreExports: string, context: import('eslint').Rule.RuleContext) => Set<string>}
|
||
|
*/
|
||
|
function resolveFiles(src, ignoreExports, context) {
|
||
|
var extensions = Array.from((0, _ignore.getFileExtensions)(context.settings));
|
||
|
|
||
|
var srcFileList = listFilesToProcess(src, extensions, context);
|
||
|
|
||
|
// prepare list of ignored files
|
||
|
var ignoredFilesList = listFilesToProcess(ignoreExports, extensions, context);
|
||
|
|
||
|
// The modern api will return a list of file paths, rather than an object
|
||
|
if (ignoredFilesList.length && typeof ignoredFilesList[0] === 'string') {
|
||
|
ignoredFilesList.forEach(function (filename) {return ignoredFiles.add(filename);});
|
||
|
} else {
|
||
|
ignoredFilesList.forEach(function (_ref4) {var filename = _ref4.filename;return ignoredFiles.add(filename);});
|
||
|
}
|
||
|
|
||
|
// prepare list of source files, don't consider files from node_modules
|
||
|
var resolvedFiles = srcFileList.length && typeof srcFileList[0] === 'string' ?
|
||
|
srcFileList.filter(function (filePath) {return !isNodeModule(filePath);}) :
|
||
|
(0, _arrayPrototype2['default'])(srcFileList, function (_ref5) {var filename = _ref5.filename;return isNodeModule(filename) ? [] : filename;});
|
||
|
|
||
|
return new Set(resolvedFiles);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* parse all source files and build up 2 maps containing the existing imports and exports
|
||
|
*/
|
||
|
var prepareImportsAndExports = function prepareImportsAndExports(srcFiles, context) {
|
||
|
var exportAll = new Map();
|
||
|
srcFiles.forEach(function (file) {
|
||
|
var exports = new Map();
|
||
|
var imports = new Map();
|
||
|
var currentExports = _builder2['default'].get(file, context);
|
||
|
if (currentExports) {var
|
||
|
|
||
|
dependencies =
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
currentExports.dependencies,reexports = currentExports.reexports,localImportList = currentExports.imports,namespace = currentExports.namespace,visitorKeys = currentExports.visitorKeys;
|
||
|
|
||
|
visitorKeyMap.set(file, visitorKeys);
|
||
|
// dependencies === export * from
|
||
|
var currentExportAll = new Set();
|
||
|
dependencies.forEach(function (getDependency) {
|
||
|
var dependency = getDependency();
|
||
|
if (dependency === null) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
currentExportAll.add(dependency.path);
|
||
|
});
|
||
|
exportAll.set(file, currentExportAll);
|
||
|
|
||
|
reexports.forEach(function (value, key) {
|
||
|
if (key === DEFAULT) {
|
||
|
exports.set(IMPORT_DEFAULT_SPECIFIER, { whereUsed: new Set() });
|
||
|
} else {
|
||
|
exports.set(key, { whereUsed: new Set() });
|
||
|
}
|
||
|
var reexport = value.getImport();
|
||
|
if (!reexport) {
|
||
|
return;
|
||
|
}
|
||
|
var localImport = imports.get(reexport.path);
|
||
|
var currentValue = void 0;
|
||
|
if (value.local === DEFAULT) {
|
||
|
currentValue = IMPORT_DEFAULT_SPECIFIER;
|
||
|
} else {
|
||
|
currentValue = value.local;
|
||
|
}
|
||
|
if (typeof localImport !== 'undefined') {
|
||
|
localImport = new Set([].concat(_toConsumableArray(localImport), [currentValue]));
|
||
|
} else {
|
||
|
localImport = new Set([currentValue]);
|
||
|
}
|
||
|
imports.set(reexport.path, localImport);
|
||
|
});
|
||
|
|
||
|
localImportList.forEach(function (value, key) {
|
||
|
if (isNodeModule(key)) {
|
||
|
return;
|
||
|
}
|
||
|
var localImport = imports.get(key) || new Set();
|
||
|
value.declarations.forEach(function (_ref6) {var importedSpecifiers = _ref6.importedSpecifiers;
|
||
|
importedSpecifiers.forEach(function (specifier) {
|
||
|
localImport.add(specifier);
|
||
|
});
|
||
|
});
|
||
|
imports.set(key, localImport);
|
||
|
});
|
||
|
importList.set(file, imports);
|
||
|
|
||
|
// build up export list only, if file is not ignored
|
||
|
if (ignoredFiles.has(file)) {
|
||
|
return;
|
||
|
}
|
||
|
namespace.forEach(function (value, key) {
|
||
|
if (key === DEFAULT) {
|
||
|
exports.set(IMPORT_DEFAULT_SPECIFIER, { whereUsed: new Set() });
|
||
|
} else {
|
||
|
exports.set(key, { whereUsed: new Set() });
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
exports.set(EXPORT_ALL_DECLARATION, { whereUsed: new Set() });
|
||
|
exports.set(IMPORT_NAMESPACE_SPECIFIER, { whereUsed: new Set() });
|
||
|
exportList.set(file, exports);
|
||
|
});
|
||
|
exportAll.forEach(function (value, key) {
|
||
|
value.forEach(function (val) {
|
||
|
var currentExports = exportList.get(val);
|
||
|
if (currentExports) {
|
||
|
var currentExport = currentExports.get(EXPORT_ALL_DECLARATION);
|
||
|
currentExport.whereUsed.add(key);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* traverse through all imports and add the respective path to the whereUsed-list
|
||
|
* of the corresponding export
|
||
|
*/
|
||
|
var determineUsage = function determineUsage() {
|
||
|
importList.forEach(function (listValue, listKey) {
|
||
|
listValue.forEach(function (value, key) {
|
||
|
var exports = exportList.get(key);
|
||
|
if (typeof exports !== 'undefined') {
|
||
|
value.forEach(function (currentImport) {
|
||
|
var specifier = void 0;
|
||
|
if (currentImport === IMPORT_NAMESPACE_SPECIFIER) {
|
||
|
specifier = IMPORT_NAMESPACE_SPECIFIER;
|
||
|
} else if (currentImport === IMPORT_DEFAULT_SPECIFIER) {
|
||
|
specifier = IMPORT_DEFAULT_SPECIFIER;
|
||
|
} else {
|
||
|
specifier = currentImport;
|
||
|
}
|
||
|
if (typeof specifier !== 'undefined') {
|
||
|
var exportStatement = exports.get(specifier);
|
||
|
if (typeof exportStatement !== 'undefined') {var
|
||
|
whereUsed = exportStatement.whereUsed;
|
||
|
whereUsed.add(listKey);
|
||
|
exports.set(specifier, { whereUsed: whereUsed });
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var getSrc = function getSrc(src) {
|
||
|
if (src) {
|
||
|
return src;
|
||
|
}
|
||
|
return [process.cwd()];
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* prepare the lists of existing imports and exports - should only be executed once at
|
||
|
* the start of a new eslint run
|
||
|
*/
|
||
|
/** @type {Set<string>} */
|
||
|
var srcFiles = void 0;
|
||
|
var lastPrepareKey = void 0;
|
||
|
var doPreparation = function doPreparation(src, ignoreExports, context) {
|
||
|
var prepareKey = JSON.stringify({
|
||
|
src: (src || []).sort(),
|
||
|
ignoreExports: (ignoreExports || []).sort(),
|
||
|
extensions: Array.from((0, _ignore.getFileExtensions)(context.settings)).sort() });
|
||
|
|
||
|
if (prepareKey === lastPrepareKey) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
importList.clear();
|
||
|
exportList.clear();
|
||
|
ignoredFiles.clear();
|
||
|
filesOutsideSrc.clear();
|
||
|
|
||
|
srcFiles = resolveFiles(getSrc(src), ignoreExports, context);
|
||
|
prepareImportsAndExports(srcFiles, context);
|
||
|
determineUsage();
|
||
|
lastPrepareKey = prepareKey;
|
||
|
};
|
||
|
|
||
|
var newNamespaceImportExists = function newNamespaceImportExists(specifiers) {return specifiers.some(function (_ref7) {var type = _ref7.type;return type === IMPORT_NAMESPACE_SPECIFIER;});};
|
||
|
|
||
|
var newDefaultImportExists = function newDefaultImportExists(specifiers) {return specifiers.some(function (_ref8) {var type = _ref8.type;return type === IMPORT_DEFAULT_SPECIFIER;});};
|
||
|
|
||
|
var fileIsInPkg = function fileIsInPkg(file) {var _readPkgUp =
|
||
|
(0, _readPkgUp3['default'])({ cwd: file }),path = _readPkgUp.path,pkg = _readPkgUp.pkg;
|
||
|
var basePath = (0, _path.dirname)(path);
|
||
|
|
||
|
var checkPkgFieldString = function checkPkgFieldString(pkgField) {
|
||
|
if ((0, _path.join)(basePath, pkgField) === file) {
|
||
|
return true;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var checkPkgFieldObject = function checkPkgFieldObject(pkgField) {
|
||
|
var pkgFieldFiles = (0, _arrayPrototype2['default'])((0, _object2['default'])(pkgField), function (value) {return typeof value === 'boolean' ? [] : (0, _path.join)(basePath, value);});
|
||
|
|
||
|
if ((0, _arrayIncludes2['default'])(pkgFieldFiles, file)) {
|
||
|
return true;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var checkPkgField = function checkPkgField(pkgField) {
|
||
|
if (typeof pkgField === 'string') {
|
||
|
return checkPkgFieldString(pkgField);
|
||
|
}
|
||
|
|
||
|
if ((typeof pkgField === 'undefined' ? 'undefined' : _typeof(pkgField)) === 'object') {
|
||
|
return checkPkgFieldObject(pkgField);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
if (pkg['private'] === true) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if (pkg.bin) {
|
||
|
if (checkPkgField(pkg.bin)) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (pkg.browser) {
|
||
|
if (checkPkgField(pkg.browser)) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (pkg.main) {
|
||
|
if (checkPkgFieldString(pkg.main)) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
};
|
||
|
|
||
|
module.exports = {
|
||
|
meta: {
|
||
|
type: 'suggestion',
|
||
|
docs: {
|
||
|
category: 'Helpful warnings',
|
||
|
description: 'Forbid modules without exports, or exports without matching import in another module.',
|
||
|
url: (0, _docsUrl2['default'])('no-unused-modules') },
|
||
|
|
||
|
schema: [{
|
||
|
properties: {
|
||
|
src: {
|
||
|
description: 'files/paths to be analyzed (only for unused exports)',
|
||
|
type: 'array',
|
||
|
uniqueItems: true,
|
||
|
items: {
|
||
|
type: 'string',
|
||
|
minLength: 1 } },
|
||
|
|
||
|
|
||
|
ignoreExports: {
|
||
|
description: 'files/paths for which unused exports will not be reported (e.g module entry points)',
|
||
|
type: 'array',
|
||
|
uniqueItems: true,
|
||
|
items: {
|
||
|
type: 'string',
|
||
|
minLength: 1 } },
|
||
|
|
||
|
|
||
|
missingExports: {
|
||
|
description: 'report modules without any exports',
|
||
|
type: 'boolean' },
|
||
|
|
||
|
unusedExports: {
|
||
|
description: 'report exports without any usage',
|
||
|
type: 'boolean' },
|
||
|
|
||
|
ignoreUnusedTypeExports: {
|
||
|
description: 'ignore type exports without any usage',
|
||
|
type: 'boolean' } },
|
||
|
|
||
|
|
||
|
anyOf: [
|
||
|
{
|
||
|
properties: {
|
||
|
unusedExports: { 'enum': [true] },
|
||
|
src: {
|
||
|
minItems: 1 } },
|
||
|
|
||
|
|
||
|
required: ['unusedExports'] },
|
||
|
|
||
|
{
|
||
|
properties: {
|
||
|
missingExports: { 'enum': [true] } },
|
||
|
|
||
|
required: ['missingExports'] }] }] },
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
create: function () {function create(context) {var _ref9 =
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
context.options[0] || {},src = _ref9.src,_ref9$ignoreExports = _ref9.ignoreExports,ignoreExports = _ref9$ignoreExports === undefined ? [] : _ref9$ignoreExports,missingExports = _ref9.missingExports,unusedExports = _ref9.unusedExports,ignoreUnusedTypeExports = _ref9.ignoreUnusedTypeExports;
|
||
|
|
||
|
if (unusedExports) {
|
||
|
doPreparation(src, ignoreExports, context);
|
||
|
}
|
||
|
|
||
|
var file = context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename();
|
||
|
|
||
|
var checkExportPresence = function () {function checkExportPresence(node) {
|
||
|
if (!missingExports) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (ignoredFiles.has(file)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var exportCount = exportList.get(file);
|
||
|
var exportAll = exportCount.get(EXPORT_ALL_DECLARATION);
|
||
|
var namespaceImports = exportCount.get(IMPORT_NAMESPACE_SPECIFIER);
|
||
|
|
||
|
exportCount['delete'](EXPORT_ALL_DECLARATION);
|
||
|
exportCount['delete'](IMPORT_NAMESPACE_SPECIFIER);
|
||
|
if (exportCount.size < 1) {
|
||
|
// node.body[0] === 'undefined' only happens, if everything is commented out in the file
|
||
|
// being linted
|
||
|
context.report(node.body[0] ? node.body[0] : node, 'No exports found');
|
||
|
}
|
||
|
exportCount.set(EXPORT_ALL_DECLARATION, exportAll);
|
||
|
exportCount.set(IMPORT_NAMESPACE_SPECIFIER, namespaceImports);
|
||
|
}return checkExportPresence;}();
|
||
|
|
||
|
var checkUsage = function () {function checkUsage(node, exportedValue, isTypeExport) {
|
||
|
if (!unusedExports) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (isTypeExport && ignoreUnusedTypeExports) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (ignoredFiles.has(file)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (fileIsInPkg(file)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (filesOutsideSrc.has(file)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// make sure file to be linted is included in source files
|
||
|
if (!srcFiles.has(file)) {
|
||
|
srcFiles = resolveFiles(getSrc(src), ignoreExports, context);
|
||
|
if (!srcFiles.has(file)) {
|
||
|
filesOutsideSrc.add(file);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
exports = exportList.get(file);
|
||
|
|
||
|
if (!exports) {
|
||
|
console.error('file `' + String(file) + '` has no exports. Please update to the latest, and if it still happens, report this on https://github.com/import-js/eslint-plugin-import/issues/2866!');
|
||
|
}
|
||
|
|
||
|
// special case: export * from
|
||
|
var exportAll = exports.get(EXPORT_ALL_DECLARATION);
|
||
|
if (typeof exportAll !== 'undefined' && exportedValue !== IMPORT_DEFAULT_SPECIFIER) {
|
||
|
if (exportAll.whereUsed.size > 0) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// special case: namespace import
|
||
|
var namespaceImports = exports.get(IMPORT_NAMESPACE_SPECIFIER);
|
||
|
if (typeof namespaceImports !== 'undefined') {
|
||
|
if (namespaceImports.whereUsed.size > 0) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// exportsList will always map any imported value of 'default' to 'ImportDefaultSpecifier'
|
||
|
var exportsKey = exportedValue === DEFAULT ? IMPORT_DEFAULT_SPECIFIER : exportedValue;
|
||
|
|
||
|
var exportStatement = exports.get(exportsKey);
|
||
|
|
||
|
var value = exportsKey === IMPORT_DEFAULT_SPECIFIER ? DEFAULT : exportsKey;
|
||
|
|
||
|
if (typeof exportStatement !== 'undefined') {
|
||
|
if (exportStatement.whereUsed.size < 1) {
|
||
|
context.report(
|
||
|
node, 'exported declaration \'' +
|
||
|
value + '\' not used within other modules');
|
||
|
|
||
|
}
|
||
|
} else {
|
||
|
context.report(
|
||
|
node, 'exported declaration \'' +
|
||
|
value + '\' not used within other modules');
|
||
|
|
||
|
}
|
||
|
}return checkUsage;}();
|
||
|
|
||
|
/**
|
||
|
* only useful for tools like vscode-eslint
|
||
|
*
|
||
|
* update lists of existing exports during runtime
|
||
|
*/
|
||
|
var updateExportUsage = function () {function updateExportUsage(node) {
|
||
|
if (ignoredFiles.has(file)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var exports = exportList.get(file);
|
||
|
|
||
|
// new module has been created during runtime
|
||
|
// include it in further processing
|
||
|
if (typeof exports === 'undefined') {
|
||
|
exports = new Map();
|
||
|
}
|
||
|
|
||
|
var newExports = new Map();
|
||
|
var newExportIdentifiers = new Set();
|
||
|
|
||
|
node.body.forEach(function (_ref10) {var type = _ref10.type,declaration = _ref10.declaration,specifiers = _ref10.specifiers;
|
||
|
if (type === EXPORT_DEFAULT_DECLARATION) {
|
||
|
newExportIdentifiers.add(IMPORT_DEFAULT_SPECIFIER);
|
||
|
}
|
||
|
if (type === EXPORT_NAMED_DECLARATION) {
|
||
|
if (specifiers.length > 0) {
|
||
|
specifiers.forEach(function (specifier) {
|
||
|
if (specifier.exported) {
|
||
|
newExportIdentifiers.add(specifier.exported.name || specifier.exported.value);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
forEachDeclarationIdentifier(declaration, function (name) {
|
||
|
newExportIdentifiers.add(name);
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// old exports exist within list of new exports identifiers: add to map of new exports
|
||
|
exports.forEach(function (value, key) {
|
||
|
if (newExportIdentifiers.has(key)) {
|
||
|
newExports.set(key, value);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// new export identifiers added: add to map of new exports
|
||
|
newExportIdentifiers.forEach(function (key) {
|
||
|
if (!exports.has(key)) {
|
||
|
newExports.set(key, { whereUsed: new Set() });
|
||
|
}
|
||
|
});
|
||
|
|
||
|
// preserve information about namespace imports
|
||
|
var exportAll = exports.get(EXPORT_ALL_DECLARATION);
|
||
|
var namespaceImports = exports.get(IMPORT_NAMESPACE_SPECIFIER);
|
||
|
|
||
|
if (typeof namespaceImports === 'undefined') {
|
||
|
namespaceImports = { whereUsed: new Set() };
|
||
|
}
|
||
|
|
||
|
newExports.set(EXPORT_ALL_DECLARATION, exportAll);
|
||
|
newExports.set(IMPORT_NAMESPACE_SPECIFIER, namespaceImports);
|
||
|
exportList.set(file, newExports);
|
||
|
}return updateExportUsage;}();
|
||
|
|
||
|
/**
|
||
|
* only useful for tools like vscode-eslint
|
||
|
*
|
||
|
* update lists of existing imports during runtime
|
||
|
*/
|
||
|
var updateImportUsage = function () {function updateImportUsage(node) {
|
||
|
if (!unusedExports) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var oldImportPaths = importList.get(file);
|
||
|
if (typeof oldImportPaths === 'undefined') {
|
||
|
oldImportPaths = new Map();
|
||
|
}
|
||
|
|
||
|
var oldNamespaceImports = new Set();
|
||
|
var newNamespaceImports = new Set();
|
||
|
|
||
|
var oldExportAll = new Set();
|
||
|
var newExportAll = new Set();
|
||
|
|
||
|
var oldDefaultImports = new Set();
|
||
|
var newDefaultImports = new Set();
|
||
|
|
||
|
var oldImports = new Map();
|
||
|
var newImports = new Map();
|
||
|
oldImportPaths.forEach(function (value, key) {
|
||
|
if (value.has(EXPORT_ALL_DECLARATION)) {
|
||
|
oldExportAll.add(key);
|
||
|
}
|
||
|
if (value.has(IMPORT_NAMESPACE_SPECIFIER)) {
|
||
|
oldNamespaceImports.add(key);
|
||
|
}
|
||
|
if (value.has(IMPORT_DEFAULT_SPECIFIER)) {
|
||
|
oldDefaultImports.add(key);
|
||
|
}
|
||
|
value.forEach(function (val) {
|
||
|
if (
|
||
|
val !== IMPORT_NAMESPACE_SPECIFIER &&
|
||
|
val !== IMPORT_DEFAULT_SPECIFIER)
|
||
|
{
|
||
|
oldImports.set(val, key);
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
function processDynamicImport(source) {
|
||
|
if (source.type !== 'Literal') {
|
||
|
return null;
|
||
|
}
|
||
|
var p = (0, _resolve2['default'])(source.value, context);
|
||
|
if (p == null) {
|
||
|
return null;
|
||
|
}
|
||
|
newNamespaceImports.add(p);
|
||
|
}
|
||
|
|
||
|
(0, _visit2['default'])(node, visitorKeyMap.get(file), {
|
||
|
ImportExpression: function () {function ImportExpression(child) {
|
||
|
processDynamicImport(child.source);
|
||
|
}return ImportExpression;}(),
|
||
|
CallExpression: function () {function CallExpression(child) {
|
||
|
if (child.callee.type === 'Import') {
|
||
|
processDynamicImport(child.arguments[0]);
|
||
|
}
|
||
|
}return CallExpression;}() });
|
||
|
|
||
|
|
||
|
node.body.forEach(function (astNode) {
|
||
|
var resolvedPath = void 0;
|
||
|
|
||
|
// support for export { value } from 'module'
|
||
|
if (astNode.type === EXPORT_NAMED_DECLARATION) {
|
||
|
if (astNode.source) {
|
||
|
resolvedPath = (0, _resolve2['default'])(astNode.source.raw.replace(/('|")/g, ''), context);
|
||
|
astNode.specifiers.forEach(function (specifier) {
|
||
|
var name = specifier.local.name || specifier.local.value;
|
||
|
if (name === DEFAULT) {
|
||
|
newDefaultImports.add(resolvedPath);
|
||
|
} else {
|
||
|
newImports.set(name, resolvedPath);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (astNode.type === EXPORT_ALL_DECLARATION) {
|
||
|
resolvedPath = (0, _resolve2['default'])(astNode.source.raw.replace(/('|")/g, ''), context);
|
||
|
newExportAll.add(resolvedPath);
|
||
|
}
|
||
|
|
||
|
if (astNode.type === IMPORT_DECLARATION) {
|
||
|
resolvedPath = (0, _resolve2['default'])(astNode.source.raw.replace(/('|")/g, ''), context);
|
||
|
if (!resolvedPath) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (isNodeModule(resolvedPath)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (newNamespaceImportExists(astNode.specifiers)) {
|
||
|
newNamespaceImports.add(resolvedPath);
|
||
|
}
|
||
|
|
||
|
if (newDefaultImportExists(astNode.specifiers)) {
|
||
|
newDefaultImports.add(resolvedPath);
|
||
|
}
|
||
|
|
||
|
astNode.specifiers.
|
||
|
filter(function (specifier) {return specifier.type !== IMPORT_DEFAULT_SPECIFIER && specifier.type !== IMPORT_NAMESPACE_SPECIFIER;}).
|
||
|
forEach(function (specifier) {
|
||
|
newImports.set(specifier.imported.name || specifier.imported.value, resolvedPath);
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
newExportAll.forEach(function (value) {
|
||
|
if (!oldExportAll.has(value)) {
|
||
|
var imports = oldImportPaths.get(value);
|
||
|
if (typeof imports === 'undefined') {
|
||
|
imports = new Set();
|
||
|
}
|
||
|
imports.add(EXPORT_ALL_DECLARATION);
|
||
|
oldImportPaths.set(value, imports);
|
||
|
|
||
|
var _exports = exportList.get(value);
|
||
|
var currentExport = void 0;
|
||
|
if (typeof _exports !== 'undefined') {
|
||
|
currentExport = _exports.get(EXPORT_ALL_DECLARATION);
|
||
|
} else {
|
||
|
_exports = new Map();
|
||
|
exportList.set(value, _exports);
|
||
|
}
|
||
|
|
||
|
if (typeof currentExport !== 'undefined') {
|
||
|
currentExport.whereUsed.add(file);
|
||
|
} else {
|
||
|
var whereUsed = new Set();
|
||
|
whereUsed.add(file);
|
||
|
_exports.set(EXPORT_ALL_DECLARATION, { whereUsed: whereUsed });
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
oldExportAll.forEach(function (value) {
|
||
|
if (!newExportAll.has(value)) {
|
||
|
var imports = oldImportPaths.get(value);
|
||
|
imports['delete'](EXPORT_ALL_DECLARATION);
|
||
|
|
||
|
var _exports2 = exportList.get(value);
|
||
|
if (typeof _exports2 !== 'undefined') {
|
||
|
var currentExport = _exports2.get(EXPORT_ALL_DECLARATION);
|
||
|
if (typeof currentExport !== 'undefined') {
|
||
|
currentExport.whereUsed['delete'](file);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
newDefaultImports.forEach(function (value) {
|
||
|
if (!oldDefaultImports.has(value)) {
|
||
|
var imports = oldImportPaths.get(value);
|
||
|
if (typeof imports === 'undefined') {
|
||
|
imports = new Set();
|
||
|
}
|
||
|
imports.add(IMPORT_DEFAULT_SPECIFIER);
|
||
|
oldImportPaths.set(value, imports);
|
||
|
|
||
|
var _exports3 = exportList.get(value);
|
||
|
var currentExport = void 0;
|
||
|
if (typeof _exports3 !== 'undefined') {
|
||
|
currentExport = _exports3.get(IMPORT_DEFAULT_SPECIFIER);
|
||
|
} else {
|
||
|
_exports3 = new Map();
|
||
|
exportList.set(value, _exports3);
|
||
|
}
|
||
|
|
||
|
if (typeof currentExport !== 'undefined') {
|
||
|
currentExport.whereUsed.add(file);
|
||
|
} else {
|
||
|
var whereUsed = new Set();
|
||
|
whereUsed.add(file);
|
||
|
_exports3.set(IMPORT_DEFAULT_SPECIFIER, { whereUsed: whereUsed });
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
oldDefaultImports.forEach(function (value) {
|
||
|
if (!newDefaultImports.has(value)) {
|
||
|
var imports = oldImportPaths.get(value);
|
||
|
imports['delete'](IMPORT_DEFAULT_SPECIFIER);
|
||
|
|
||
|
var _exports4 = exportList.get(value);
|
||
|
if (typeof _exports4 !== 'undefined') {
|
||
|
var currentExport = _exports4.get(IMPORT_DEFAULT_SPECIFIER);
|
||
|
if (typeof currentExport !== 'undefined') {
|
||
|
currentExport.whereUsed['delete'](file);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
newNamespaceImports.forEach(function (value) {
|
||
|
if (!oldNamespaceImports.has(value)) {
|
||
|
var imports = oldImportPaths.get(value);
|
||
|
if (typeof imports === 'undefined') {
|
||
|
imports = new Set();
|
||
|
}
|
||
|
imports.add(IMPORT_NAMESPACE_SPECIFIER);
|
||
|
oldImportPaths.set(value, imports);
|
||
|
|
||
|
var _exports5 = exportList.get(value);
|
||
|
var currentExport = void 0;
|
||
|
if (typeof _exports5 !== 'undefined') {
|
||
|
currentExport = _exports5.get(IMPORT_NAMESPACE_SPECIFIER);
|
||
|
} else {
|
||
|
_exports5 = new Map();
|
||
|
exportList.set(value, _exports5);
|
||
|
}
|
||
|
|
||
|
if (typeof currentExport !== 'undefined') {
|
||
|
currentExport.whereUsed.add(file);
|
||
|
} else {
|
||
|
var whereUsed = new Set();
|
||
|
whereUsed.add(file);
|
||
|
_exports5.set(IMPORT_NAMESPACE_SPECIFIER, { whereUsed: whereUsed });
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
oldNamespaceImports.forEach(function (value) {
|
||
|
if (!newNamespaceImports.has(value)) {
|
||
|
var imports = oldImportPaths.get(value);
|
||
|
imports['delete'](IMPORT_NAMESPACE_SPECIFIER);
|
||
|
|
||
|
var _exports6 = exportList.get(value);
|
||
|
if (typeof _exports6 !== 'undefined') {
|
||
|
var currentExport = _exports6.get(IMPORT_NAMESPACE_SPECIFIER);
|
||
|
if (typeof currentExport !== 'undefined') {
|
||
|
currentExport.whereUsed['delete'](file);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
newImports.forEach(function (value, key) {
|
||
|
if (!oldImports.has(key)) {
|
||
|
var imports = oldImportPaths.get(value);
|
||
|
if (typeof imports === 'undefined') {
|
||
|
imports = new Set();
|
||
|
}
|
||
|
imports.add(key);
|
||
|
oldImportPaths.set(value, imports);
|
||
|
|
||
|
var _exports7 = exportList.get(value);
|
||
|
var currentExport = void 0;
|
||
|
if (typeof _exports7 !== 'undefined') {
|
||
|
currentExport = _exports7.get(key);
|
||
|
} else {
|
||
|
_exports7 = new Map();
|
||
|
exportList.set(value, _exports7);
|
||
|
}
|
||
|
|
||
|
if (typeof currentExport !== 'undefined') {
|
||
|
currentExport.whereUsed.add(file);
|
||
|
} else {
|
||
|
var whereUsed = new Set();
|
||
|
whereUsed.add(file);
|
||
|
_exports7.set(key, { whereUsed: whereUsed });
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
oldImports.forEach(function (value, key) {
|
||
|
if (!newImports.has(key)) {
|
||
|
var imports = oldImportPaths.get(value);
|
||
|
imports['delete'](key);
|
||
|
|
||
|
var _exports8 = exportList.get(value);
|
||
|
if (typeof _exports8 !== 'undefined') {
|
||
|
var currentExport = _exports8.get(key);
|
||
|
if (typeof currentExport !== 'undefined') {
|
||
|
currentExport.whereUsed['delete'](file);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}return updateImportUsage;}();
|
||
|
|
||
|
return {
|
||
|
'Program:exit': function () {function ProgramExit(node) {
|
||
|
updateExportUsage(node);
|
||
|
updateImportUsage(node);
|
||
|
checkExportPresence(node);
|
||
|
}return ProgramExit;}(),
|
||
|
ExportDefaultDeclaration: function () {function ExportDefaultDeclaration(node) {
|
||
|
checkUsage(node, IMPORT_DEFAULT_SPECIFIER, false);
|
||
|
}return ExportDefaultDeclaration;}(),
|
||
|
ExportNamedDeclaration: function () {function ExportNamedDeclaration(node) {
|
||
|
node.specifiers.forEach(function (specifier) {
|
||
|
checkUsage(specifier, specifier.exported.name || specifier.exported.value, false);
|
||
|
});
|
||
|
forEachDeclarationIdentifier(node.declaration, function (name, isTypeExport) {
|
||
|
checkUsage(node, name, isTypeExport);
|
||
|
});
|
||
|
}return ExportNamedDeclaration;}() };
|
||
|
|
||
|
}return create;}() };
|
||
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby11bnVzZWQtbW9kdWxlcy5qcyJdLCJuYW1lcyI6WyJyZXF1aXJlRmlsZUVudW1lcmF0b3IiLCJGaWxlRW51bWVyYXRvciIsInJlcXVpcmUiLCJlIiwiY29kZSIsImxpc3RGaWxlc1VzaW5nRmlsZUVudW1lcmF0b3IiLCJzcmMiLCJleHRlbnNpb25zIiwiQXJyYXkiLCJmcm9tIiwiaXRlcmF0ZUZpbGVzIiwiZmlsZVBhdGgiLCJpZ25vcmVkIiwiZmlsZW5hbWUiLCJsaXN0RmlsZXNXaXRoTGVnYWN5RnVuY3Rpb25zIiwib3JpZ2luYWxMaXN0RmlsZXNUb1Byb2Nlc3MiLCJsaXN0RmlsZXNUb1Byb2Nlc3MiLCJwYXR0ZXJucyIsImNvbmNhdCIsInBhdHRlcm4iLCJtYXAiLCJleHRlbnNpb24iLCJ0ZXN0IiwibGlzdEZpbGVzV2l0aE1vZGVybkFwaSIsInNyY1BhdGhzIiwic2Vzc2lvbiIsImZpbGVzIiwiaSIsImVudHJpZXMiLCJkZWVwRmlsdGVyIiwiZW50cnkiLCJmdWxsRW50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