From fb88af2ecf797f014bfe0b38994f040a535dcdba Mon Sep 17 00:00:00 2001 From: JounQin Date: Mon, 4 Jul 2022 11:58:16 +0800 Subject: [PATCH] fix: try index file with extensions automatically (#131) --- .changeset/violet-lamps-rush.md | 5 +++++ src/index.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/violet-lamps-rush.md diff --git a/.changeset/violet-lamps-rush.md b/.changeset/violet-lamps-rush.md new file mode 100644 index 0000000..440d50a --- /dev/null +++ b/.changeset/violet-lamps-rush.md @@ -0,0 +1,5 @@ +--- +"eslint-import-resolver-typescript": patch +--- + +fix: try index file with extensions automatically diff --git a/src/index.ts b/src/index.ts index f5694fd..a762c7c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -268,6 +268,7 @@ function getMappedPath( extensions = defaultExtensions, retry?: boolean, ): string | undefined { + const originalExtensions = extensions extensions = ['', ...extensions] let paths: string[] | undefined = [] @@ -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)