lint: add Biome (lint only) and fix its findings

This commit is contained in:
Callum Alpass committed 2026-11-02 22:40:44 +11:00
1 parent d5b6406cae
commit 441d9d6ed3
14 files changed
+125 -22

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
{
"$schema": "https://biomejs.dev/schemas/2.5.15/schema.json",
"formatter": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": "off",
"correctness": {
"useExhaustiveDependencies": "off"
},
"style": {
"noNonNullAssertion": "off"
},
"suspicious": {
"noArrayIndexKey": "off"
}
}
},
"overrides": [
{
"includes": [
"src/ui/App.tsx",
"src/model/hints.ts",
"src/ui/HintBar.tsx",
"src/ui/Palette.tsx",
"src/model/palette.ts"
],
"linter": {
"enabled": false
}
}
]
}
+19
View File
@@ -16,6 +16,7 @@
"zustand": "5.0.11",
},
"devDependencies": {
"@biomejs/biome": "2.5.15",
"@noble/hashes": "1.8.0",
"@types/bun": "latest",
"@types/react": "^19.3.0",
@@ -25,6 +26,24 @@
},
},
"packages": {
"@biomejs/biome": ["@biomejs/biome@2.5.15", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.5.15", "@biomejs/cli-darwin-x64": "2.5.15", "@biomejs/cli-linux-arm64": "2.5.15", "@biomejs/cli-linux-arm64-musl": "2.5.15", "@biomejs/cli-linux-x64": "2.5.15", "@biomejs/cli-linux-x64-musl": "2.5.15", "@biomejs/cli-win32-arm64": "2.5.15", "@biomejs/cli-win32-x64": "2.5.15" }, "bin": { "biome": "bin/biome" } }, "sha512-WZTW4slm/pdkh92K6t/3aEN++44JD1PQ7squ7RCMLI1flHGl43DVOIGXvCjHiZgBMO1V4uYxoFNtqrIA4qGuIQ=="],
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.5.15", "", { "os": "darwin", "cpu": "arm64" }, "sha512-BZVzFhJ/mUvTLMYbc9x6el0o2Uv5zP7bACYyhFb6fSc1giroXm7PL0a5KqMJ9F+/BnkYRjagD/ROSDVOZ6eapg=="],
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.5.15", "", { "os": "darwin", "cpu": "x64" }, "sha512-V5Kw63V+fVGNFhFrizDxMbGXAzZCh8kYzJpy3GI6gTapWDg7bZK9oYC9CbVgQSEdTnupz0U5Efz8Ev+5vdBBXw=="],
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.5.15", "", { "os": "linux", "cpu": "arm64" }, "sha512-XaG7P7eeSLYETD3K9grfB0mQmpLQZjygdbsxekWBJAg4am79fGAtRpfRyNnTvXB2fZFNnJZG3nXm7HBat0+VUw=="],
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.5.15", "", { "os": "linux", "cpu": "arm64" }, "sha512-tGzZUTcJCV7tj5Adh/Gn6nR4MycqA3iohq2LEcrarAgRBkU0h0OKd2UzCRkOsOYOuUGaUJb4YmqRqyy2feGGSw=="],
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.5.15", "", { "os": "linux", "cpu": "x64" }, "sha512-xE4iEW/3LqlYj9GFgGrFsFSH51dEEpUbYWBfeOv0q87WkUDxK2o/HhreSb7qMJqck70RVM6Lg96hgedcAYcOkA=="],
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.5.15", "", { "os": "linux", "cpu": "x64" }, "sha512-IlxUcyxilVGPsE008x13pWdkTbU3nQpP2i9b5UrbOYj6goBkKsRX1XB7yJLcV+O1H9LBchIIm4adOaVLZBX0ZQ=="],
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.5.15", "", { "os": "win32", "cpu": "arm64" }, "sha512-2kPKzhNlm8C+Ru3GcO0Me2ODkCBLrVOUNuyi84RJyWDVKAA4+Kjj3jMjL938lF6BRfvltC4vB2nPY9SvN51Ovg=="],
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.5.15", "", { "os": "win32", "cpu": "x64" }, "sha512-yAzh4UqEImV6Hcy0zjUqNfJAsUhoD64FBQCdTG8Md/Z2wQeVP/ZmJ3XRYAs1g8J9fjTFyl2fCtc5FB5til47+g=="],
"@noble/hashes": ["@noble/hashes@1.8.0", "", {}, "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A=="],
"@opentui/core": ["@opentui/core@0.2.7", "", { "dependencies": { "bun-ffi-structs": "0.2.2", "diff": "9.0.0", "marked": "17.0.1", "string-width": "7.2.0", "strip-ansi": "7.1.2", "yoga-layout": "3.2.1" }, "optionalDependencies": { "@opentui/core-darwin-arm64": "0.2.7", "@opentui/core-darwin-x64": "0.2.7", "@opentui/core-linux-arm64": "0.2.7", "@opentui/core-linux-x64": "0.2.7", "@opentui/core-win32-arm64": "0.2.7", "@opentui/core-win32-x64": "0.2.7" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "sha512-cnN6JcaGC7SeQzobBy/CHzqUAQFtypazuw1CjQBo7WwoOiLMGubt9W5FXeF0zIrSxH2Ed6NLWhPYRg7SD4629Q=="],
+2
View File
@@ -9,6 +9,7 @@
"scripts": {
"dev": "bun run src/bin.ts",
"typecheck": "tsc --noEmit",
"lint": "biome lint src test",
"test": "bun test",
"postinstall": "bun run scripts/link-vendor.ts"
},
@@ -24,6 +25,7 @@
"zustand": "5.0.11"
},
"devDependencies": {
"@biomejs/biome": "2.5.15",
"@noble/hashes": "1.8.0",
"@types/bun": "latest",
"@types/react": "^19.3.0",
+6 -3
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bun
import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts";
import type { OrchestrationV2ShellSnapshot, ThreadId } from "@t3tools/contracts";
import { T3Session } from "./client/session.ts";
import { findThread, lastActivity, relativeTime, rowTime, shortId, statusLabel, threadRows } from "./model/threads.ts";
@@ -88,7 +88,10 @@ async function tmuxCommand(args: string[]) {
let pending = false;
let syncing = false;
const sync = async () => {
if (syncing) return void (pending = true);
if (syncing) {
pending = true;
return;
}
syncing = true;
try {
const latest = session.getShell().snapshot;
@@ -115,7 +118,7 @@ async function tmuxCommand(args: string[]) {
async function runUi(attachNeedle?: string) {
const { session, snapshot } = await connectedSession();
let attachThreadId;
let attachThreadId: ThreadId | undefined;
if (attachNeedle) {
const thread = findThread(snapshot, attachNeedle);
if (!thread) {
+4 -1
View File
@@ -365,7 +365,10 @@ export class T3Session {
watchCommandOutput(threadId: ThreadId, itemId: TurnItemId, listener: Listener<CommandOutputView>, onError: Listener<string>): () => void {
let view = EMPTY_COMMAND_OUTPUT;
const fiber = this.runInScope(this.requireConnection().rpc[ORCHESTRATION_V2_WS_METHODS.subscribeCommandOutput]({ threadId, itemId }).pipe(
Stream.runForEach((frame) => Effect.sync(() => listener(view = applyCommandOutputFrame(view, frame)))),
Stream.runForEach((frame) => Effect.sync(() => {
view = applyCommandOutputFrame(view, frame);
listener(view);
})),
Effect.catchCause((cause) => Effect.sync(() => onError(prettyCause(cause)))),
));
return () => { Effect.runFork(Fiber.interrupt(fiber)); };
+1 -1
View File
@@ -228,7 +228,7 @@ function automationLine(task: ScheduledTask, now: number, timestampFormat: Tui3C
task.schedule.type === "interval"
? `every ${formatWorkingDurationLabel(task.schedule.everyMs)}`
: task.schedule.type === "fixed_time"
? `${task.schedule.weekdays && task.schedule.weekdays.length < 7 ? task.schedule.weekdays.map((day) => WEEKDAYS[day]).join(",") + " " : "daily "}${formatClock(task.schedule.timeOfDay, timestampFormat)}`
? `${task.schedule.weekdays && task.schedule.weekdays.length < 7 ? `${task.schedule.weekdays.map((day) => WEEKDAYS[day]).join(",")} ` : "daily "}${formatClock(task.schedule.timeOfDay, timestampFormat)}`
: "on webhook";
if (!task.enabled) return { task, schedule, status: "off", tone: "muted" };
if (task.lastRunStatus === "running") return { task, schedule, status: "running", tone: "info" };
+1 -1
View File
@@ -11,7 +11,7 @@ export interface PatchFile {
/** Retains both paths so renamed and deleted files expand against the right revisions. */
export function splitPatch(patch: string): PatchFile[] {
return patch.split(/^(?=diff --git )/m).filter((chunk) => chunk.startsWith("diff --git ")).map((chunk) => {
let parsed;
let parsed: ReturnType<typeof parsePatch>[number] | undefined;
try { parsed = parsePatch(chunk.split(/^@@ /m)[0]!)[0]; } catch { /* A truncated preview can end inside a file header. */ }
const oldPath = cleanPath(parsed?.oldFileName ?? /^diff --git a\/(.+?) b\//.exec(chunk)?.[1] ?? "file");
const newPath = cleanPath(parsed?.newFileName ?? oldPath);
+1
View File
@@ -18,6 +18,7 @@ export function ring(): void {
* either ignore it. In tmux it needs `set -g allow-passthrough on`.
*/
export function desktopNotify(title: string, body: string): void {
// biome-ignore lint/suspicious/noControlCharactersInRegex: the control characters are what is being stripped
const clean = (text: string) => text.replace(/[\x00-\x1f\x7f;]/g, " ").slice(0, 200);
const sequence = process.env.KITTY_WINDOW_ID
? `\x1b]99;i=tui3:d=0;${clean(title)}\x1b\\\x1b]99;i=tui3:p=body;${clean(body)}\x1b\\`
+24 -9
View File
@@ -114,29 +114,44 @@ export function useQueue(input: {
switch (event.name) {
case "j":
case "down":
return setFocus(Math.min(queued.length - 1, focus + 1)), true;
setFocus(Math.min(queued.length - 1, focus + 1));
return true;
case "k":
case "up":
return setFocus(Math.max(0, focus - 1)), true;
setFocus(Math.max(0, focus - 1));
return true;
case "return":
case "s":
return sendNow(message), true;
sendNow(message);
return true;
case "e":
return beginEdit(message), true;
beginEdit(message);
return true;
case "x":
case "d":
case "backspace":
return remove(message), true;
remove(message);
return true;
case "escape":
case "q":
return setFocus(null), true;
setFocus(null);
return true;
}
return false;
}
if (mode === "nav" && event.name === "q" && event.shift && queued.length > 0) return setFocus(0), true;
if (mode === "nav" && event.name === "q" && event.shift && queued.length > 0) {
setFocus(0);
return true;
}
// The web's alt+↑: edit the last queued message.
if (mode === "input" && event.meta && event.name === "up" && !editing && queued.length > 0) return beginEdit(queued[queued.length - 1]!), true;
if (mode === "input" && event.name === "escape" && editing) return cancelEdit(), true;
if (mode === "input" && event.meta && event.name === "up" && !editing && queued.length > 0) {
beginEdit(queued[queued.length - 1]!);
return true;
}
if (mode === "input" && event.name === "escape" && editing) {
cancelEdit();
return true;
}
return false;
};
+8 -2
View File
@@ -47,8 +47,14 @@ export function useSecretRequest(input: { readonly session: T3Session; readonly
if (!request) return false;
if (value === null) {
if (!nav) return false;
if (event.name === "return") return setValue(""), true;
if (event.name === "x" && !questionPending) return answer({ type: "decline" }), true;
if (event.name === "return") {
setValue("");
return true;
}
if (event.name === "x" && !questionPending) {
answer({ type: "decline" });
return true;
}
return false;
}
if (event.ctrl && event.name === "c") return false;
+12 -2
View File
@@ -78,7 +78,12 @@ describe("commands tui3 dispatches", () => {
test("a new thread launches with a payload the server accepts", async () => {
const session = new T3Session();
let payload: unknown;
const rpc = { "orchestration.launchThread": (input: unknown) => ((payload = input), Effect.succeed({ threadId: ThreadId.make("new-1") })) };
const rpc = {
"orchestration.launchThread": (input: unknown) => {
payload = input;
return Effect.succeed({ threadId: ThreadId.make("new-1") });
},
};
(session as unknown as { connection: unknown }).connection = { rpc };
const id = await session.launchThread({
projectId: ProjectId.make("p1"),
@@ -104,7 +109,12 @@ describe("commands tui3 dispatches", () => {
const launching = new T3Session();
let payload: unknown;
const rpc = { "orchestration.launchThread": (input: unknown) => ((payload = input), Effect.succeed({ threadId: ThreadId.make("new-2") })) };
const rpc = {
"orchestration.launchThread": (input: unknown) => {
payload = input;
return Effect.succeed({ threadId: ThreadId.make("new-2") });
},
};
(launching as unknown as { connection: unknown }).connection = { rpc };
await launching.launchThread({
projectId: ProjectId.make("p1"),
+4 -1
View File
@@ -5,7 +5,10 @@ import { splitPatch, wholeFilePatch } from "../src/model/diffs.ts";
const changed = "diff --git a/a.ts b/a.ts\n--- a/a.ts\n+++ b/a.ts\n@@ -2 +2 @@\n-old\n+new\n";
test("diff files retain old paths and change types for contents requests", () => {
const files = splitPatch(changed + "diff --git a/old.ts b/new.ts\nsimilarity index 100%\nrename from old.ts\nrename to new.ts\n" + "diff --git a/gone.ts b/gone.ts\ndeleted file mode 100644\n--- a/gone.ts\n+++ /dev/null\n@@ -1 +0,0 @@\n-gone\n" + "diff --git a/add.ts b/add.ts\nnew file mode 100644\n--- /dev/null\n+++ b/add.ts\n@@ -0,0 +1 @@\n+added\n");
const renamed = "diff --git a/old.ts b/new.ts\nsimilarity index 100%\nrename from old.ts\nrename to new.ts\n";
const deleted = "diff --git a/gone.ts b/gone.ts\ndeleted file mode 100644\n--- a/gone.ts\n+++ /dev/null\n@@ -1 +0,0 @@\n-gone\n";
const added = "diff --git a/add.ts b/add.ts\nnew file mode 100644\n--- /dev/null\n+++ b/add.ts\n@@ -0,0 +1 @@\n+added\n";
const files = splitPatch(`${changed}${renamed}${deleted}${added}`);
expect(files.map(({ path, oldPath, changeType }) => ({ path, oldPath, changeType }))).toEqual([
{ path: "a.ts", oldPath: "a.ts", changeType: "change" }, { path: "new.ts", oldPath: "old.ts", changeType: "rename-pure" },
{ path: "gone.ts", oldPath: "gone.ts", changeType: "deleted" }, { path: "add.ts", oldPath: "add.ts", changeType: "new" },
+4 -1
View File
@@ -261,7 +261,10 @@ describe("pull request commands and payloads", () => {
const payloads = new Map<string, unknown>();
const capture =
(method: string, result: unknown) =>
(input: unknown) => (payloads.set(method, input), Effect.succeed(result));
(input: unknown) => {
payloads.set(method, input);
return Effect.succeed(result);
};
const rpc = {
"pullRequests.list": capture("list", listResult([])),
"pullRequests.detail": capture("detail", detail()),
+3 -1
View File
@@ -77,7 +77,9 @@ describe("workspace RPC payloads (no live mutations)", () => {
await session.cancelWorktreeSetup(threadId);
expect(sent.map((call) => call.method)).toEqual(["vcs.switchRef", "vcs.createRef", "vcs.pull", "vcs.createWorktree", "vcs.removeWorktree", "shell.openInEditor", "worktreeSetup.cancel"]);
const schemas = [VcsSwitchRefInput, VcsCreateRefInput, VcsPullInput, VcsCreateWorktreeInput, VcsRemoveWorktreeInput, LaunchEditorInput, WorktreeSetupCancelInput];
schemas.forEach((schema, index) => expect(Schema.is(schema)(sent[index]!.input)).toBe(true));
schemas.forEach((schema, index) => {
expect(Schema.is(schema)(sent[index]!.input)).toBe(true);
});
expect(sent[1]!.input).toMatchObject({ switchRef: true });
expect(sent[3]!.input).toEqual({ cwd: "/repo", refName: "main", newRefName: "new-work", path: null });
expect(sent[4]!.input).not.toHaveProperty("force");