chore: migrate to oxlint and oxfmt

Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-14 14:31:43 +00:00
parent 912ebffc63
commit c379191f80
1480 changed files with 28608 additions and 43547 deletions

View File

@@ -13,10 +13,7 @@ import {
resolveBrowserExecutableForPlatform,
stopClawdChrome,
} from "./chrome.js";
import {
DEFAULT_CLAWD_BROWSER_COLOR,
DEFAULT_CLAWD_BROWSER_PROFILE_NAME,
} from "./constants.js";
import { DEFAULT_CLAWD_BROWSER_COLOR, DEFAULT_CLAWD_BROWSER_PROFILE_NAME } from "./constants.js";
async function readJson(filePath: string): Promise<Record<string, unknown>> {
const raw = await fsp.readFile(filePath, "utf-8");
@@ -30,9 +27,7 @@ describe("browser chrome profile decoration", () => {
});
it("writes expected name + signed ARGB seed to Chrome prefs", async () => {
const userDataDir = await fsp.mkdtemp(
path.join(os.tmpdir(), "clawdbot-chrome-test-"),
);
const userDataDir = await fsp.mkdtemp(path.join(os.tmpdir(), "clawdbot-chrome-test-"));
try {
decorateClawdProfile(userDataDir, { color: DEFAULT_CLAWD_BROWSER_COLOR });
@@ -50,9 +45,7 @@ describe("browser chrome profile decoration", () => {
expect(def.default_avatar_fill_color).toBe(expectedSignedArgb);
expect(def.default_avatar_stroke_color).toBe(expectedSignedArgb);
const prefs = await readJson(
path.join(userDataDir, "Default", "Preferences"),
);
const prefs = await readJson(path.join(userDataDir, "Default", "Preferences"));
const browser = prefs.browser as Record<string, unknown>;
const theme = browser.theme as Record<string, unknown>;
const autogenerated = prefs.autogenerated as Record<string, unknown>;
@@ -72,9 +65,7 @@ describe("browser chrome profile decoration", () => {
});
it("best-effort writes name when color is invalid", async () => {
const userDataDir = await fsp.mkdtemp(
path.join(os.tmpdir(), "clawdbot-chrome-test-"),
);
const userDataDir = await fsp.mkdtemp(path.join(os.tmpdir(), "clawdbot-chrome-test-"));
try {
decorateClawdProfile(userDataDir, { color: "lobster-orange" });
const localState = await readJson(path.join(userDataDir, "Local State"));
@@ -90,9 +81,7 @@ describe("browser chrome profile decoration", () => {
});
it("recovers from missing/invalid preference files", async () => {
const userDataDir = await fsp.mkdtemp(
path.join(os.tmpdir(), "clawdbot-chrome-test-"),
);
const userDataDir = await fsp.mkdtemp(path.join(os.tmpdir(), "clawdbot-chrome-test-"));
try {
await fsp.mkdir(path.join(userDataDir, "Default"), { recursive: true });
await fsp.writeFile(path.join(userDataDir, "Local State"), "{", "utf-8"); // invalid JSON
@@ -107,9 +96,7 @@ describe("browser chrome profile decoration", () => {
const localState = await readJson(path.join(userDataDir, "Local State"));
expect(typeof localState.profile).toBe("object");
const prefs = await readJson(
path.join(userDataDir, "Default", "Preferences"),
);
const prefs = await readJson(path.join(userDataDir, "Default", "Preferences"));
expect(typeof prefs.profile).toBe("object");
} finally {
await fsp.rm(userDataDir, { recursive: true, force: true });
@@ -117,16 +104,12 @@ describe("browser chrome profile decoration", () => {
});
it("is idempotent when rerun on an existing profile", async () => {
const userDataDir = await fsp.mkdtemp(
path.join(os.tmpdir(), "clawdbot-chrome-test-"),
);
const userDataDir = await fsp.mkdtemp(path.join(os.tmpdir(), "clawdbot-chrome-test-"));
try {
decorateClawdProfile(userDataDir, { color: DEFAULT_CLAWD_BROWSER_COLOR });
decorateClawdProfile(userDataDir, { color: DEFAULT_CLAWD_BROWSER_COLOR });
const prefs = await readJson(
path.join(userDataDir, "Default", "Preferences"),
);
const prefs = await readJson(path.join(userDataDir, "Default", "Preferences"));
const profile = prefs.profile as Record<string, unknown>;
expect(profile.name).toBe(DEFAULT_CLAWD_BROWSER_PROFILE_NAME);
} finally {
@@ -171,9 +154,7 @@ describe("browser chrome helpers", () => {
it("finds Chrome in Program Files on Windows", () => {
const marker = path.win32.join("Program Files", "Google", "Chrome");
const exists = vi
.spyOn(fs, "existsSync")
.mockImplementation((p) => String(p).includes(marker));
const exists = vi.spyOn(fs, "existsSync").mockImplementation((p) => String(p).includes(marker));
const exe = findChromeExecutableWindows();
expect(exe?.kind).toBe("chrome");
expect(exe?.path).toMatch(/chrome\.exe$/);
@@ -197,9 +178,7 @@ describe("browser chrome helpers", () => {
"Application",
"chrome.exe",
);
const exists = vi
.spyOn(fs, "existsSync")
.mockImplementation((p) => String(p).includes(marker));
const exists = vi.spyOn(fs, "existsSync").mockImplementation((p) => String(p).includes(marker));
const exe = resolveBrowserExecutableForPlatform(
{} as Parameters<typeof resolveBrowserExecutableForPlatform>[0],
"win32",
@@ -217,9 +196,7 @@ describe("browser chrome helpers", () => {
json: async () => ({ webSocketDebuggerUrl: "ws://127.0.0.1/devtools" }),
} as unknown as Response),
);
await expect(isChromeReachable("http://127.0.0.1:12345", 50)).resolves.toBe(
true,
);
await expect(isChromeReachable("http://127.0.0.1:12345", 50)).resolves.toBe(true);
vi.stubGlobal(
"fetch",
@@ -228,14 +205,10 @@ describe("browser chrome helpers", () => {
json: async () => ({}),
} as unknown as Response),
);
await expect(isChromeReachable("http://127.0.0.1:12345", 50)).resolves.toBe(
false,
);
await expect(isChromeReachable("http://127.0.0.1:12345", 50)).resolves.toBe(false);
vi.stubGlobal("fetch", vi.fn().mockRejectedValue(new Error("boom")));
await expect(isChromeReachable("http://127.0.0.1:12345", 50)).resolves.toBe(
false,
);
await expect(isChromeReachable("http://127.0.0.1:12345", 50)).resolves.toBe(false);
});
it("stopClawdChrome no-ops when process is already killed", async () => {