chore(lint): enable stricter oxlint rules

This commit is contained in:
Peter Steinberger
2026-05-31 18:43:54 +01:00
parent cb569f6ad9
commit 304e2c83c0
615 changed files with 3603 additions and 3701 deletions

View File

@@ -144,7 +144,7 @@ async function runCommand(
args: string[],
timeoutMs: number,
): Promise<{ stdout: string; status: number | null }> {
return await new Promise((resolve) => {
return await new Promise((resolveLocal) => {
let stdout = "";
let child: ReturnType<typeof spawn>;
try {
@@ -153,7 +153,7 @@ async function runCommand(
windowsHide: true,
});
} catch {
resolve({ stdout: "", status: null });
resolveLocal({ stdout: "", status: null });
return;
}
const timeout = setTimeout(() => {
@@ -167,11 +167,11 @@ async function runCommand(
});
child.on("error", () => {
clearTimeout(timeout);
resolve({ stdout: "", status: null });
resolveLocal({ stdout: "", status: null });
});
child.on("close", (status) => {
clearTimeout(timeout);
resolve({ stdout, status });
resolveLocal({ stdout, status });
});
});
}

View File

@@ -4,11 +4,7 @@ import path from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { LOCAL_EMBEDDING_WORKER_ERROR_CODES } from "./embedding-worker-errors.js";
import { createLocalEmbeddingWorkerProvider } from "./embeddings-worker.js";
import {
createLocalEmbeddingProvider,
createLocalEmbeddingProviderInProcess,
DEFAULT_LOCAL_MODEL,
} from "./embeddings.js";
import { createLocalEmbeddingProviderInProcess, DEFAULT_LOCAL_MODEL } from "./embeddings.js";
const nodeLlamaMock = vi.hoisted(() => ({
importNodeLlamaCpp: vi.fn(),

View File

@@ -136,25 +136,25 @@ export async function createLocalEmbeddingProviderInProcess(
return {
id: "local",
model: modelPath,
embedQuery: async (text, options) => {
embedQuery: async (text, optionsValue) => {
throwIfClosed();
options?.signal?.throwIfAborted();
optionsValue?.signal?.throwIfAborted();
const ctx = await ensureContext();
throwIfClosed();
options?.signal?.throwIfAborted();
optionsValue?.signal?.throwIfAborted();
const embedding = await ctx.getEmbeddingFor(text);
return sanitizeAndNormalizeEmbedding(Array.from(embedding.vector));
},
embedBatch: async (texts, options) => {
embedBatch: async (texts, optionsLocal) => {
throwIfClosed();
options?.signal?.throwIfAborted();
optionsLocal?.signal?.throwIfAborted();
const ctx = await ensureContext();
throwIfClosed();
options?.signal?.throwIfAborted();
optionsLocal?.signal?.throwIfAborted();
const embeddings: number[][] = [];
for (const text of texts) {
throwIfClosed();
options?.signal?.throwIfAborted();
optionsLocal?.signal?.throwIfAborted();
const embedding = await ctx.getEmbeddingFor(text);
embeddings.push(sanitizeAndNormalizeEmbedding(Array.from(embedding.vector)));
}

View File

@@ -992,7 +992,7 @@ describe("OpenClaw SDK", () => {
await oc.connect();
const observedLast = (async () => {
for await (const event of oc.events(
(event) => event.raw?.event === "chat" && event.raw.seq === 501,
(eventLocal) => eventLocal.raw?.event === "chat" && eventLocal.raw.seq === 501,
)) {
return event;
}

View File

@@ -187,7 +187,7 @@ function wrapLine(text: string, width: number): string[] {
return params.every((param) => Number.isInteger(param)) ? params : null;
};
const activeSgrAfter = (tokens: Token[]) => {
const activeSgrAfter = (tokensValue: Token[]) => {
type SgrCategory =
| "background"
| "blink"
@@ -272,7 +272,7 @@ function wrapLine(text: string, width: number): string[] {
}
return false;
};
for (const token of tokens) {
for (const token of tokensValue) {
if (token.kind !== "ansi") {
continue;
}
@@ -314,17 +314,17 @@ function wrapLine(text: string, width: number): string[] {
lines.push(cleaned);
};
const trimLeadingSpaces = (tokens: Token[]) => {
const trimLeadingSpaces = (tokensLocal: Token[]) => {
while (true) {
const firstCharIndex = tokens.findIndex((token) => token.kind === "char");
if (firstCharIndex < 0) {
const firstCharIndexLocal = tokensLocal.findIndex((token) => token.kind === "char");
if (firstCharIndexLocal < 0) {
return;
}
const firstChar = tokens[firstCharIndex];
const firstChar = tokensLocal[firstCharIndexLocal];
if (!firstChar || !isSpaceChar(firstChar.value)) {
return;
}
tokens.splice(firstCharIndex, 1);
tokensLocal.splice(firstCharIndexLocal, 1);
}
};
@@ -513,8 +513,8 @@ export function renderTable(opts: RenderTableOptions): string {
// If we have room and any flex columns, expand them to fill the available width.
// This keeps tables from looking "clipped" and reduces wrapping in wide terminals.
if (maxWidth) {
const sepCount = columns.length + 1;
const currentTotal = widths.reduce((a, b) => a + b, 0) + sepCount;
const sepCountLocal = columns.length + 1;
const currentTotal = widths.reduce((a, b) => a + b, 0) + sepCountLocal;
let extra = maxWidth - currentTotal;
if (extra > 0) {
const flexCols = columns