Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/oxlint/src-js/js_config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getErrorMessage } from "./utils/utils.ts";
import { isDefineConfig } from "./package/config.ts";
import { JSONStringify } from "./utils/globals.ts";
import { DateNow, JSONStringify } from "./utils/globals.ts";

interface JsConfigResult {
path: string;
Expand Down Expand Up @@ -89,9 +89,11 @@ function validateConfigExtends(root: object): void {
*/
export async function loadJsConfigs(paths: string[]): Promise<string> {
try {
const cacheKey = DateNow();
const results = await Promise.allSettled(
paths.map(async (path): Promise<JsConfigResult> => {
const fileUrl = new URL(`file://${path}`);
// Bypass Node.js module cache to allow reloading changed config files (used for LSP, where we reload configs after important changes)
const fileUrl = new URL(`file://${path}?cache=${cacheKey}`);
const module = await import(fileUrl.href);
const config = module.default;

Expand Down
2 changes: 2 additions & 0 deletions apps/oxlint/src-js/utils/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ export const { ownKeys: ReflectOwnKeys } = Reflect;
export const { iterator: SymbolIterator } = Symbol;

export const { fromCodePoint: StringFromCodePoint } = String;

export const { now: DateNow } = Date;
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ help: Remove the debugger statement
ts-config/test.ts
--- Diagnostics ---------
> 1 | debugger;
| ^^^^^^^^^ Error: \`debugger\` statement is not allowed
| ^^^^^^^^^ Warning: \`debugger\` statement is not allowed
help: Remove the debugger statement
--------------------"
`;
3 changes: 3 additions & 0 deletions apps/oxlint/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ export function normalizeStdout(stdout: string, fixtureName: string, isESLint: b
return `${prefix}${content.replaceAll("\\", "/")}${suffix}`;
});

// Handle uris with `?cache=...` query param, which are used to bypass Node.js module cache when loading config files in LSP tests.
line = line.replaceAll(/\?cache=\d+/g, "");

// Handle stack trace lines.
// e.g. ` at file:///path/to/oxc/apps/oxlint/test/fixtures/foo/bar.js:1:1`
// e.g. ` at whatever (file:///path/to/oxc/apps/oxlint/test/fixtures/foo/bar.js:1:1)`
Expand Down
Loading