From fa075576de487d0af7b373e573c947441d93e5e7 Mon Sep 17 00:00:00 2001 From: Vodopyanov Egor Date: Wed, 27 Mar 2024 20:14:58 +0900 Subject: [PATCH] fix: check exports exist before access to it --- src/rules/no-unused-modules.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rules/no-unused-modules.js b/src/rules/no-unused-modules.js index 812efffbc..ec3551673 100644 --- a/src/rules/no-unused-modules.js +++ b/src/rules/no-unused-modules.js @@ -534,7 +534,7 @@ module.exports = { } // special case: export * from - const exportAll = exports.get(EXPORT_ALL_DECLARATION); + const exportAll = exports && exports.get(EXPORT_ALL_DECLARATION); if (typeof exportAll !== 'undefined' && exportedValue !== IMPORT_DEFAULT_SPECIFIER) { if (exportAll.whereUsed.size > 0) { return; @@ -542,7 +542,7 @@ module.exports = { } // special case: namespace import - const namespaceImports = exports.get(IMPORT_NAMESPACE_SPECIFIER); + const namespaceImports = exports && exports.get(IMPORT_NAMESPACE_SPECIFIER); if (typeof namespaceImports !== 'undefined') { if (namespaceImports.whereUsed.size > 0) { return; @@ -552,7 +552,7 @@ module.exports = { // exportsList will always map any imported value of 'default' to 'ImportDefaultSpecifier' const exportsKey = exportedValue === DEFAULT ? IMPORT_DEFAULT_SPECIFIER : exportedValue; - const exportStatement = exports.get(exportsKey); + const exportStatement = exports && exports.get(exportsKey); const value = exportsKey === IMPORT_DEFAULT_SPECIFIER ? DEFAULT : exportsKey;