mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-08 03:22:55 +00:00
chore(lint): enable stricter oxlint rules
This commit is contained in:
@@ -91,36 +91,36 @@ export const installHooksFromPath: AsyncUnknownMock = vi.fn();
|
||||
export const recordHookInstall: UnknownMock = vi.fn();
|
||||
|
||||
const { defaultRuntime, runtimeLogs, runtimeErrors, resetRuntimeCapture } = vi.hoisted(() => {
|
||||
const runtimeLogs: string[] = [];
|
||||
const runtimeErrors: string[] = [];
|
||||
const runtimeLogsLocal: string[] = [];
|
||||
const runtimeErrorsLocal: string[] = [];
|
||||
const stringifyArgs = (args: unknown[]) => args.map((value) => String(value)).join(" ");
|
||||
const normalizeStdout = (value: string) => (value.endsWith("\n") ? value.slice(0, -1) : value);
|
||||
const stringifyJson = (value: unknown, space = 2) =>
|
||||
JSON.stringify(value, null, space > 0 ? space : undefined);
|
||||
const defaultRuntime = {
|
||||
const defaultRuntimeLocal = {
|
||||
log: vi.fn((...args: unknown[]) => {
|
||||
runtimeLogs.push(stringifyArgs(args));
|
||||
runtimeLogsLocal.push(stringifyArgs(args));
|
||||
}),
|
||||
error: vi.fn((...args: unknown[]) => {
|
||||
runtimeErrors.push(stringifyArgs(args));
|
||||
runtimeErrorsLocal.push(stringifyArgs(args));
|
||||
}),
|
||||
writeStdout: vi.fn((value: string) => {
|
||||
defaultRuntime.log(normalizeStdout(value));
|
||||
defaultRuntimeLocal.log(normalizeStdout(value));
|
||||
}),
|
||||
writeJson: vi.fn((value: unknown, space = 2) => {
|
||||
defaultRuntime.log(stringifyJson(value, space));
|
||||
defaultRuntimeLocal.log(stringifyJson(value, space));
|
||||
}),
|
||||
exit: vi.fn((code: number) => {
|
||||
throw new Error(`__exit__:${code}`);
|
||||
}),
|
||||
} as CliMockOutputRuntime;
|
||||
return {
|
||||
defaultRuntime,
|
||||
runtimeLogs,
|
||||
runtimeErrors,
|
||||
defaultRuntime: defaultRuntimeLocal,
|
||||
runtimeLogs: runtimeLogsLocal,
|
||||
runtimeErrors: runtimeErrorsLocal,
|
||||
resetRuntimeCapture: () => {
|
||||
runtimeLogs.length = 0;
|
||||
runtimeErrors.length = 0;
|
||||
runtimeLogsLocal.length = 0;
|
||||
runtimeErrorsLocal.length = 0;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user