Skip to content

Commit

Permalink
fix(plugin-eslint): ensure file url scheme needed for dynamic imports…
Browse files Browse the repository at this point in the history
… on Windows
  • Loading branch information
matejchalk committed Nov 23, 2024
1 parent abbd764 commit 91c7678
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/plugin-eslint/src/lib/meta/versions/flat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -54,9 +55,9 @@ async function loadConfigByDefaultLocation(): Promise<FlatConfig> {
}

async function loadConfigByPath(path: string): Promise<FlatConfig> {
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;
}

Expand Down

0 comments on commit 91c7678

Please sign in to comment.