From afeb928b304e7196b10f71aec873fca739a9ad93 Mon Sep 17 00:00:00 2001 From: Xinyan Chen Date: Wed, 7 Sep 2022 22:13:12 +0800 Subject: [PATCH] perf: disable `throwIfNoEntry` on Node 14+ (#182) Co-authored-by: JounQin --- .changeset/cyan-parrots-act.md | 5 +++++ src/index.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/cyan-parrots-act.md diff --git a/.changeset/cyan-parrots-act.md b/.changeset/cyan-parrots-act.md new file mode 100644 index 0000000..49e6f85 --- /dev/null +++ b/.changeset/cyan-parrots-act.md @@ -0,0 +1,5 @@ +--- +"eslint-import-resolver-typescript": patch +--- + +perf: disable `throwIfNoEntry` on Node 14+ diff --git a/src/index.ts b/src/index.ts index 195148b..b8e1707 100644 --- a/src/index.ts +++ b/src/index.ts @@ -243,8 +243,9 @@ function removeQuerystring(id: string) { const isFile = (path?: string | undefined): path is string => { try { - return !!path && fs.statSync(path).isFile() + return !!(path && fs.statSync(path, { throwIfNoEntry: false })?.isFile()) } catch { + // Node 12 does not support throwIfNoEntry. return false } }