From 91c7678c749eef4fe9da5d2fe98cbeca33a95724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Chalk?= Date: Fri, 22 Nov 2024 11:26:19 +0100 Subject: [PATCH] fix(plugin-eslint): ensure file url scheme needed for dynamic imports on Windows --- packages/plugin-eslint/src/lib/meta/versions/flat.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/plugin-eslint/src/lib/meta/versions/flat.ts b/packages/plugin-eslint/src/lib/meta/versions/flat.ts index 2b1b97255..2fca56c38 100644 --- a/packages/plugin-eslint/src/lib/meta/versions/flat.ts +++ b/packages/plugin-eslint/src/lib/meta/versions/flat.ts @@ -2,6 +2,7 @@ import type { Linter, Rule } from 'eslint'; // eslint-disable-next-line import/no-deprecated import { builtinRules } from 'eslint/use-at-your-own-risk'; import { isAbsolute, join } from 'node:path'; +import { pathToFileURL } from 'node:url'; import { exists, findNearestFile, toArray, ui } from '@code-pushup/utils'; import type { ESLintTarget } from '../../config'; import { jsonHash } from '../hash'; @@ -54,9 +55,9 @@ async function loadConfigByDefaultLocation(): Promise { } async function loadConfigByPath(path: string): Promise { - const mod = (await import( - isAbsolute(path) ? path : join(process.cwd(), path) - )) as FlatConfig | { default: FlatConfig }; + const absolutePath = isAbsolute(path) ? path : join(process.cwd(), path); + const url = pathToFileURL(absolutePath).toString(); + const mod = (await import(url)) as FlatConfig | { default: FlatConfig }; return 'default' in mod ? mod.default : mod; }