From 3db97c2c4c6eb6367e59f7f67b4870960bc360f2 Mon Sep 17 00:00:00 2001 From: tintinweb Date: Sun, 22 Mar 2026 20:29:00 +0100 Subject: [PATCH] linter fixes --- src/index.ts | 14 +++++++------- src/process-tracker.ts | 2 +- src/task-store.ts | 4 ++-- src/tasks-config.ts | 4 ++-- src/ui/settings-menu.ts | 2 +- test/process-tracker.test.ts | 4 ++-- test/subagent-integration.test.ts | 15 ++++++++++----- test/task-store.test.ts | 9 ++++----- test/task-widget.test.ts | 4 ++-- 9 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/index.ts b/src/index.ts index fafc7e8..921ec0b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,15 +14,15 @@ * /tasks — Interactive task management menu */ -import type { ExtensionAPI, ExtensionContext, ExtensionCommandContext } from "@mariozechner/pi-coding-agent"; -import { Type } from "@sinclair/typebox"; -import { TaskStore } from "./task-store.js"; -import { ProcessTracker } from "./process-tracker.js"; -import { TaskWidget, type UICtx } from "./ui/task-widget.js"; -import { loadTasksConfig } from "./tasks-config.js"; -import { openSettingsMenu } from "./ui/settings-menu.js"; import { randomUUID } from "node:crypto"; import { join, resolve } from "node:path"; +import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@mariozechner/pi-coding-agent"; +import { Type } from "@sinclair/typebox"; +import { ProcessTracker } from "./process-tracker.js"; +import { TaskStore } from "./task-store.js"; +import { loadTasksConfig } from "./tasks-config.js"; +import { openSettingsMenu } from "./ui/settings-menu.js"; +import { TaskWidget, type UICtx } from "./ui/task-widget.js"; // ---- Debug ---- diff --git a/src/process-tracker.ts b/src/process-tracker.ts index 982a5a6..31db32e 100644 --- a/src/process-tracker.ts +++ b/src/process-tracker.ts @@ -45,7 +45,7 @@ export class ProcessTracker { }); // Handle process exit - proc.on("close", (code, signal) => { + proc.on("close", (code, _signal) => { if (bp.status === "running") { bp.status = code === 0 ? "completed" : "error"; } diff --git a/src/task-store.ts b/src/task-store.ts index 88be613..c2f3263 100644 --- a/src/task-store.ts +++ b/src/task-store.ts @@ -5,9 +5,9 @@ * Shared (PI_TASK_LIST_ID set): ~/.pi/tasks/.json with file locking. */ -import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, renameSync } from "node:fs"; -import { join, dirname, isAbsolute } from "node:path"; +import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs"; import { homedir } from "node:os"; +import { dirname, isAbsolute, join } from "node:path"; import type { Task, TaskStatus, TaskStoreData } from "./types.js"; const TASKS_DIR = join(homedir(), ".pi", "tasks"); diff --git a/src/tasks-config.ts b/src/tasks-config.ts index b686c50..d45e099 100644 --- a/src/tasks-config.ts +++ b/src/tasks-config.ts @@ -1,7 +1,7 @@ // /.pi/tasks-config.json — persists extension settings across sessions -import { readFileSync, writeFileSync, mkdirSync } from "node:fs"; -import { join, dirname } from "node:path"; +import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { dirname, join } from "node:path"; export interface TasksConfig { taskScope?: "memory" | "session" | "project"; // default: "session" diff --git a/src/ui/settings-menu.ts b/src/ui/settings-menu.ts index fd7d6de..b9b8a9c 100644 --- a/src/ui/settings-menu.ts +++ b/src/ui/settings-menu.ts @@ -6,8 +6,8 @@ * own settings panel style. */ -import { SettingsList, Container, Text, Spacer, type SettingItem } from "@mariozechner/pi-tui"; import { getSettingsListTheme } from "@mariozechner/pi-coding-agent"; +import { Container, type SettingItem, SettingsList, Spacer, Text } from "@mariozechner/pi-tui"; import { saveTasksConfig, type TasksConfig } from "../tasks-config.js"; // ── Types ─────────────────────────────────────────────────────────────────── diff --git a/test/process-tracker.test.ts b/test/process-tracker.test.ts index 9854344..6594799 100644 --- a/test/process-tracker.test.ts +++ b/test/process-tracker.test.ts @@ -1,6 +1,6 @@ -import { describe, it, expect, beforeEach } from "vitest"; -import { ProcessTracker } from "../src/process-tracker.js"; import { spawn } from "node:child_process"; +import { beforeEach, describe, expect, it } from "vitest"; +import { ProcessTracker } from "../src/process-tracker.js"; describe("ProcessTracker", () => { let tracker: ProcessTracker; diff --git a/test/subagent-integration.test.ts b/test/subagent-integration.test.ts index 6ebff40..dd3c36f 100644 --- a/test/subagent-integration.test.ts +++ b/test/subagent-integration.test.ts @@ -3,10 +3,10 @@ * auto-cascade, and widget agent ID display. */ -import { describe, it, expect, beforeEach, afterEach, vi } from "vitest"; -import { TaskStore } from "../src/task-store.js"; -import { TaskWidget, type UICtx, type Theme } from "../src/ui/task-widget.js"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import initExtension from "../src/index.js"; +import { TaskStore } from "../src/task-store.js"; +import { TaskWidget, type Theme, type UICtx } from "../src/ui/task-widget.js"; // Force in-memory task store for all integration tests — prevents file-backed // store from loading stale tasks across test instances. @@ -15,6 +15,11 @@ afterEach(() => { delete process.env.PI_TASKS; }); // ---- Mock pi ---- +type MockEventBus = { + on: (channel: string, handler: (data: unknown) => void) => () => void; + emit: (channel: string, data: unknown) => void; +}; + /** Minimal mock of ExtensionAPI with events, tool capture, and event hooks. */ function mockPi() { const tools = new Map(); @@ -84,7 +89,7 @@ function mockCtx() { // ---- Mock subagents extension (RPC responders) ---- /** Simulates the @tintinweb/pi-subagents extension: responds to ping + spawn RPCs and emits ready. */ -function installSubagentsMock(pi: { events: { on: Function; emit: Function } }, opts?: { spawnError?: string }) { +function installSubagentsMock(pi: { events: MockEventBus }, opts?: { spawnError?: string }) { let idCounter = 0; const spawned: Array<{ id: string; type: string; prompt: string; options: any }> = []; const stopped: string[] = []; @@ -712,7 +717,7 @@ describe("RPC protocol correctness", () => { }); /** Install a ping-only mock with a specific protocol version (or no version for v1). */ -function installVersionedMock(pi: { events: { on: Function; emit: Function } }, version?: number) { +function installVersionedMock(pi: { events: MockEventBus }, version?: number) { const unsubPing = pi.events.on("subagents:rpc:ping", (data: unknown) => { const { requestId } = data as { requestId: string }; if (version !== undefined) { diff --git a/test/task-store.test.ts b/test/task-store.test.ts index 21f1d24..ecb7b9a 100644 --- a/test/task-store.test.ts +++ b/test/task-store.test.ts @@ -1,9 +1,8 @@ -import { describe, it, expect, beforeEach, afterEach } from "vitest"; -import { TaskStore } from "../src/task-store.js"; -import { existsSync, rmSync, mkdirSync, readFileSync } from "node:fs"; +import { readFileSync, rmSync } from "node:fs"; +import { homedir, tmpdir } from "node:os"; import { join } from "node:path"; -import { homedir } from "node:os"; -import { tmpdir } from "node:os"; +import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { TaskStore } from "../src/task-store.js"; describe("TaskStore (in-memory)", () => { let store: TaskStore; diff --git a/test/task-widget.test.ts b/test/task-widget.test.ts index 1408205..6989c4c 100644 --- a/test/task-widget.test.ts +++ b/test/task-widget.test.ts @@ -1,6 +1,6 @@ -import { describe, it, expect, beforeEach, afterEach, vi } from "vitest"; -import { TaskWidget, type UICtx, type Theme, type TaskMetrics } from "../src/ui/task-widget.js"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { TaskStore } from "../src/task-store.js"; +import { TaskWidget, type Theme, type UICtx } from "../src/ui/task-widget.js"; /** Create a mock theme that returns raw text (no ANSI escapes). */ function mockTheme(): Theme {