Skip to content

Commit

Permalink
Merge pull request #1 from ExodusMovement/egor/fix/modules
Browse files Browse the repository at this point in the history
fix: check exports exist before access to it
  • Loading branch information
headfire94 committed Mar 27, 2024
2 parents 2de78c1 + fa07557 commit eab9d9f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,15 @@ 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;
}
}

// 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;
Expand All @@ -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;

Expand Down

0 comments on commit eab9d9f

Please sign in to comment.