Skip to content

Commit

Permalink
fix: try index file with extensions automatically (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Jul 4, 2022
1 parent b012ab7 commit fb88af2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/violet-lamps-rush.md
@@ -0,0 +1,5 @@
---
"eslint-import-resolver-typescript": patch
---

fix: try index file with extensions automatically
6 changes: 5 additions & 1 deletion src/index.ts
Expand Up @@ -268,6 +268,7 @@ function getMappedPath(
extensions = defaultExtensions,
retry?: boolean,
): string | undefined {
const originalExtensions = extensions
extensions = ['', ...extensions]

let paths: string[] | undefined = []
Expand All @@ -280,7 +281,10 @@ function getMappedPath(
} else {
paths = mappers!
.map(mapper =>
mapper?.(source).map(item => extensions.map(ext => `${item}${ext}`)),
mapper?.(source).map(item => [
...extensions.map(ext => `${item}${ext}`),
...originalExtensions.map(ext => `${item}/index${ext}`),
]),
)
.flat(2)
.filter(isFile)
Expand Down

0 comments on commit fb88af2

Please sign in to comment.