Skip to content

Commit

Permalink
fix(no-named-as-default): add extra guards
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Oct 30, 2024
1 parent 630dbce commit a0bf2ee
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/rules/no-named-as-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ export = createRule<[], MessageId>({
return
}

if (!exportMapOfImported.hasDefault) {
// The rule is triggered for default imports/exports, so if the imported module has no default
// this means we're dealing with incorrect source code anyway
return
}

if (!exportMapOfImported.has(nameValue)) {
// The name used locally for the default import was not even used in the imported module.
return
}

if (
exportMapOfImported.exports.has('default') &&
exportMapOfImported.exports.has(nameValue)
Expand Down

0 comments on commit a0bf2ee

Please sign in to comment.