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

@@ -7,11 +7,7 @@ import { describe, expect, it, vi } from "vitest";
import { WebSocket } from "ws";
import { rawDataToString } from "../infra/ws.js";
import { defaultRuntime } from "../runtime.js";
import {
CANVAS_HOST_PATH,
CANVAS_WS_PATH,
injectCanvasLiveReload,
} from "./a2ui.js";
import { CANVAS_HOST_PATH, CANVAS_WS_PATH, injectCanvasLiveReload } from "./a2ui.js";
import { createCanvasHostHandler, startCanvasHost } from "./server.js";
describe("canvas host", () => {
@@ -35,9 +31,7 @@ describe("canvas host", () => {
});
try {
const res = await fetch(
`http://127.0.0.1:${server.port}${CANVAS_HOST_PATH}/`,
);
const res = await fetch(`http://127.0.0.1:${server.port}${CANVAS_HOST_PATH}/`);
const html = await res.text();
expect(res.status).toBe(200);
expect(html).toContain("Interactive test page");
@@ -51,11 +45,7 @@ describe("canvas host", () => {
it("skips live reload injection when disabled", async () => {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-canvas-"));
await fs.writeFile(
path.join(dir, "index.html"),
"<html><body>no-reload</body></html>",
"utf8",
);
await fs.writeFile(path.join(dir, "index.html"), "<html><body>no-reload</body></html>", "utf8");
const server = await startCanvasHost({
runtime: defaultRuntime,
@@ -67,17 +57,13 @@ describe("canvas host", () => {
});
try {
const res = await fetch(
`http://127.0.0.1:${server.port}${CANVAS_HOST_PATH}/`,
);
const res = await fetch(`http://127.0.0.1:${server.port}${CANVAS_HOST_PATH}/`);
const html = await res.text();
expect(res.status).toBe(200);
expect(html).toContain("no-reload");
expect(html).not.toContain(CANVAS_WS_PATH);
const wsRes = await fetch(
`http://127.0.0.1:${server.port}${CANVAS_WS_PATH}`,
);
const wsRes = await fetch(`http://127.0.0.1:${server.port}${CANVAS_WS_PATH}`);
expect(wsRes.status).toBe(404);
} finally {
await server.close();
@@ -87,11 +73,7 @@ describe("canvas host", () => {
it("serves canvas content from the mounted base path", async () => {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-canvas-"));
await fs.writeFile(
path.join(dir, "index.html"),
"<html><body>v1</body></html>",
"utf8",
);
await fs.writeFile(path.join(dir, "index.html"), "<html><body>v1</body></html>", "utf8");
const handler = await createCanvasHostHandler({
runtime: defaultRuntime,
@@ -113,9 +95,7 @@ describe("canvas host", () => {
socket.destroy();
});
await new Promise<void>((resolve) =>
server.listen(0, "127.0.0.1", resolve),
);
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
const port = (server.address() as AddressInfo).port;
try {
@@ -138,11 +118,7 @@ describe("canvas host", () => {
it("reuses a handler without closing it twice", async () => {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-canvas-"));
await fs.writeFile(
path.join(dir, "index.html"),
"<html><body>v1</body></html>",
"utf8",
);
await fs.writeFile(path.join(dir, "index.html"), "<html><body>v1</body></html>", "utf8");
const handler = await createCanvasHostHandler({
runtime: defaultRuntime,
@@ -187,22 +163,15 @@ describe("canvas host", () => {
});
try {
const res = await fetch(
`http://127.0.0.1:${server.port}${CANVAS_HOST_PATH}/`,
);
const res = await fetch(`http://127.0.0.1:${server.port}${CANVAS_HOST_PATH}/`);
const html = await res.text();
expect(res.status).toBe(200);
expect(html).toContain("v1");
expect(html).toContain(CANVAS_WS_PATH);
const ws = new WebSocket(
`ws://127.0.0.1:${server.port}${CANVAS_WS_PATH}`,
);
const ws = new WebSocket(`ws://127.0.0.1:${server.port}${CANVAS_WS_PATH}`);
await new Promise<void>((resolve, reject) => {
const timer = setTimeout(
() => reject(new Error("ws open timeout")),
2000,
);
const timer = setTimeout(() => reject(new Error("ws open timeout")), 2000);
ws.on("open", () => {
clearTimeout(timer);
resolve();
@@ -214,10 +183,7 @@ describe("canvas host", () => {
});
const msg = new Promise<string>((resolve, reject) => {
const timer = setTimeout(
() => reject(new Error("reload timeout")),
4000,
);
const timer = setTimeout(() => reject(new Error("reload timeout")), 4000);
ws.on("message", (data) => {
clearTimeout(timer);
resolve(rawDataToString(data));
@@ -245,9 +211,7 @@ describe("canvas host", () => {
});
try {
const res = await fetch(
`http://127.0.0.1:${server.port}/__clawdbot__/a2ui/`,
);
const res = await fetch(`http://127.0.0.1:${server.port}/__clawdbot__/a2ui/`);
const html = await res.text();
expect(res.status).toBe(200);
expect(html).toContain("clawdbot-a2ui-host");