Skip to content

Commit

Permalink
Ignore unresolved imports that look external but have ignored extensi…
Browse files Browse the repository at this point in the history
…on (resolves #311)
  • Loading branch information
webpro committed Oct 27, 2023
1 parent cdff59b commit e8859e7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ProjectPrincipal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,17 @@ export class ProjectPrincipal {
}
} else {
const sanitizedSpecifier = sanitizeSpecifier(specifier);
if (isMaybePackageName(sanitizedSpecifier)) {
const ext = extname(sanitizedSpecifier);
const hasIgnoredExtension = IGNORED_FILE_EXTENSIONS.includes(ext);
if (!hasIgnoredExtension && isMaybePackageName(sanitizedSpecifier)) {
// Should never end up here; maybe a dependency that was not installed.
// Package name may contain such extensions, but any external dependency should be resolved by TS.
external.add(sanitizedSpecifier);
} else {
const isIgnored = this.isGitIgnored(join(dirname(filePath), sanitizedSpecifier));
if (!isIgnored) {
const ext = extname(sanitizedSpecifier);
if (!ext || (ext !== '.json' && !IGNORED_FILE_EXTENSIONS.includes(ext))) {
if (!ext || (ext !== '.json' && !hasIgnoredExtension)) {
unresolvedImports.add(specifier);
}
}
Expand Down

0 comments on commit e8859e7

Please sign in to comment.