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

955 lines
106 KiB
JavaScript
Raw Normal View History

2022-06-23 02:27:43 +02: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 _ExportMap = require('../ExportMap');var _ExportMap2 = _interopRequireDefault(_ExportMap);
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 _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);
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);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.reduce(function (carry, pattern) {
return carry.concat(extensions.map(function (extension) {
return (/\*\*|\*\./.test(pattern) ? pattern : String(pattern) + '/**/*' + String(extension));
}));
}, src.slice());
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 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 {
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 srcFiles = new Set();
var srcFileList = listFilesToProcess(src, extensions);
// prepare list of ignored files
var ignoredFilesList = listFilesToProcess(ignoreExports, extensions);
ignoredFilesList.forEach(function (_ref3) {var filename = _ref3.filename;return ignoredFiles.add(filename);});
// prepare list of source files, don't consider files from node_modules
srcFileList.filter(function (_ref4) {var filename = _ref4.filename;return !isNodeModule(filename);}).forEach(function (_ref5) {var filename = _ref5.filename;
srcFiles.add(filename);
});
return srcFiles;
};
/**
* 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;return (
importedSpecifiers.forEach(function (specifier) {return 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, _object2['default'])(pkgField).map(function (value) {return (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: { url: (0, _docsUrl2['default'])('no-unused-modules') },
schema: [{
properties: {
src: {
description: 'files/paths to be analyzed (only for unused exports)',
type: 'array',
minItems: 1,
items: {
type: 'string',
minLength: 1 } },
ignoreExports: {
description:
'files/paths for which unused exports will not be reported (e.g module entry points)',
type: 'array',
minItems: 1,
items: {
type: 'string',
minLength: 1 } },
missingExports: {
description: 'report modules without any exports',
type: 'boolean' },
unusedExports: {
description: 'report exports without any usage',
type: 'boolean' } },
not: {
properties: {
unusedExports: { 'enum': [false] },
missingExports: { 'enum': [false] } } },
anyOf: [{
not: {
properties: {
unusedExports: { 'enum': [true] } } },
required: ['missingExports'] },
{
not: {
properties: {
missingExports: { 'enum': [true] } } },
required: ['unusedExports'] },
{
properties: {
unusedExports: { 'enum': [true] } },
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.forEach(function (specifier) {
if (specifier.type === IMPORT_DEFAULT_SPECIFIER ||
specifier.type === IMPORT_NAMESPACE_SPECIFIER) {
return;
}
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(node, 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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby11bnVzZWQtbW9kdWxlcy5qcyJdLCJuYW1lcyI6WyJGaWxlRW51bWV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