securityos/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js

945 lines
107 KiB
JavaScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
'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 _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 _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
*/var FileEnumerator = void 0;var listFilesToProcess = void 0;
try {var _require =
require('eslint/use-at-your-own-risk');FileEnumerator = _require.FileEnumerator;
} catch (e) {
try {var _require2 =
require('eslint/lib/cli-engine/file-enumerator'); // has been moved to eslint/lib/cli-engine/file-enumerator in version 6
FileEnumerator = _require2.FileEnumerator;} catch (e) {
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
listFilesToProcess = function listFilesToProcess(src, extensions) {
return originalListFilesToProcess(src, {
extensions: extensions });
};
} catch (e) {var _require4 =
require('eslint/lib/util/glob-util'),_originalListFilesToProcess = _require4.listFilesToProcess;
listFilesToProcess = function listFilesToProcess(src, extensions) {
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);
};
}
}
}
if (FileEnumerator) {
listFilesToProcess = function listFilesToProcess(src, extensions) {
var e = new FileEnumerator({
extensions: extensions });
return Array.from(e.iterateFiles(src), function (_ref) {var filePath = _ref.filePath,ignored = _ref.ignored;return {
ignored: ignored,
filename: filePath };});
};
}
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) {
if (
declaration.type === FUNCTION_DECLARATION ||
declaration.type === CLASS_DECLARATION ||
declaration.type === TS_INTERFACE_DECLARATION ||
declaration.type === TS_TYPE_ALIAS_DECLARATION ||
declaration.type === TS_ENUM_DECLARATION)
{
cb(declaration.id.name);
} else if (declaration.type === VARIABLE_DECLARATION) {
declaration.declarations.forEach(function (_ref2) {var id = _ref2.id;
if (id.type === OBJECT_PATTERN) {
(0, _ExportMap.recursivePatternCapture)(id, function (pattern) {
if (pattern.type === IDENTIFIER) {
cb(pattern.name);
}
});
} else if (id.type === ARRAY_PATTERN) {
id.elements.forEach(function (_ref3) {var name = _ref3.name;
cb(name);
});
} else {
cb(id.name);
}
});
}
}
}
/**
* 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();
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
*/
var resolveFiles = function resolveFiles(src, ignoreExports, context) {
var extensions = Array.from((0, _ignore.getFileExtensions)(context.settings));
var srcFileList = listFilesToProcess(src, extensions);
// prepare list of ignored files
var ignoredFilesList = listFilesToProcess(ignoreExports, extensions);
ignoredFilesList.forEach(function (_ref4) {var filename = _ref4.filename;return ignoredFiles.add(filename);});
// prepare list of source files, don't consider files from node_modules
return new Set(
(0, _arrayPrototype2['default'])(srcFileList, function (_ref5) {var filename = _ref5.filename;return isNodeModule(filename) ? [] : filename;}));
};
/**
* 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 = _ExportMap2['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
*/
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' } },
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;
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) {
if (!unusedExports) {
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);
// 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);
}return ExportDefaultDeclaration;}(),
ExportNamedDeclaration: function () {function ExportNamedDeclaration(node) {
node.specifiers.forEach(function (specifier) {
checkUsage(specifier, specifier.exported.name || specifier.exported.value);
});
forEachDeclarationIdentifier(node.declaration, function (name) {
checkUsage(node, name);
});
}return ExportNamedDeclaration;}() };
}return create;}() };
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyY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