Fix array-type lint

This commit is contained in:
murashit 2026-05-23 04:46:05 +09:00
parent a429ccf06c
commit 5f8ee1f46e
13 changed files with 21 additions and 15 deletions

View file

@ -133,9 +133,9 @@ function approvalSummaryParts(approval: PendingApproval): ApprovalSummaryParts {
return summaryParts(reason, null, fallback);
}
export function approvalDetails(approval: PendingApproval): Array<{ key: string; value: string }> {
export function approvalDetails(approval: PendingApproval): { key: string; value: string }[] {
const params = approval.params as Record<string, unknown>;
const rows: Array<{ key: string; value: string }> = [];
const rows: { key: string; value: string }[] = [];
addOptional(rows, "reason", params.reason);
addOptional(rows, "command", Array.isArray(params.command) ? params.command.join(" ") : params.command);
addOptional(rows, "cwd", params.cwd);

View file

@ -14,7 +14,7 @@ export function permissionRows(value: unknown): DetailRow[] {
const fileSystem = permissions.fileSystem as {
read?: unknown;
write?: unknown;
entries?: Array<{ path?: unknown; access?: unknown }>;
entries?: { path?: unknown; access?: unknown }[];
globScanMaxDepth?: unknown;
} | null;
if (!fileSystem || typeof fileSystem !== "object") return rows;

View file

@ -25,6 +25,6 @@ export function slashCommandHelpLines(): string[] {
return SLASH_COMMANDS.map((item) => `${item.command} - ${item.detail}`);
}
export function slashCommandHelpRows(): Array<{ key: string; value: string }> {
export function slashCommandHelpRows(): { key: string; value: string }[] {
return SLASH_COMMANDS.map((item) => ({ key: item.command, value: item.detail }));
}

View file

@ -59,7 +59,7 @@ export function createAutoReviewResultItem(params: AutoReviewNotification): Disp
function parseAutomaticApprovalReviewMessage(
text: string,
): { status: string; summary: string; rows: Array<{ key: string; value: string }> } | null {
): { status: string; summary: string; rows: { key: string; value: string }[] } | null {
const match = /^Automatic approval review\s+([a-zA-Z][\w-]*)(?:\s+\(([^)]*)\))?:\s*(.+)$/i.exec(text.trim());
if (!match) return null;

View file

@ -419,7 +419,7 @@ function webSearchQueryList(
}
function webSearchDetails(item: WebSearchItem): DisplayDetailSection[] {
const rows: Array<{ key: string; value: string }> = [];
const rows: { key: string; value: string }[] = [];
if (item.action) rows.push({ key: "action", value: webSearchActionLabel(item.action.type) });
if (item.action?.type === "search") {
const queries = webSearchQueryList(item.action.query, item.action.queries, item.query);

View file

@ -33,7 +33,7 @@ export function jsonDetail(title: string, value: unknown): DisplayDetailSection[
return value === null || value === undefined ? [] : [{ title, body: jsonPreview(value) }];
}
export function jsonDetails(entries: Array<[title: string, value: unknown]>): DisplayDetailSection[] {
export function jsonDetails(entries: [title: string, value: unknown][]): DisplayDetailSection[] {
return entries.flatMap(([title, value]) => jsonDetail(title, value));
}

View file

@ -20,7 +20,7 @@ export type ToolResultDisplayItem =
| ReviewResultDisplayItem;
export type ToolResultDetailSection =
| { kind: "meta"; title?: string; rows: Array<{ key: string; value: string }> }
| { kind: "meta"; title?: string; rows: { key: string; value: string }[] }
| { kind: "output"; title: string; body: string }
| { kind: "diff"; title: string; diff: string };
@ -159,7 +159,7 @@ function outputSection(title: string, body: string | null | undefined): ToolResu
return body ? [{ kind: "output", title, body }] : [];
}
function fileChangeSummary(item: DisplayItem, changes: Array<DisplayFileChange & { displayPath: string }>): string {
function fileChangeSummary(item: DisplayItem, changes: (DisplayFileChange & { displayPath: string })[]): string {
if (item.kind !== "fileChange") return item.text;
if (changes.length === 0) return item.text;
if (changes.length > 1) return item.text;

View file

@ -41,7 +41,7 @@ export interface RateLimitSummaryRow {
export interface EffectiveConfigSection {
title: string;
rows: Array<{ key: string; value: string }>;
rows: { key: string; value: string }[];
}
export function contextSummary(snapshot: RuntimeSnapshot): ContextSummary | null {

View file

@ -75,7 +75,7 @@ function renderDetailSection(parent: HTMLElement, section: ToolResultDetailSecti
renderOutputBlock(parent, section.title, section.body);
}
function renderMetaBlock(parent: HTMLElement, title: string | undefined, rows: Array<{ key: string; value: string }>): void {
function renderMetaBlock(parent: HTMLElement, title: string | undefined, rows: { key: string; value: string }[]): void {
const section = title ? renderOutputSection(parent, title, "codex-panel__output codex-panel__output--meta") : parent;
const meta = section.createEl("dl", { cls: "codex-panel__meta-grid" });
for (const row of rows) {

View file

@ -185,7 +185,7 @@ describe("approval model", () => {
});
it("builds action responses for current approval families", () => {
const requests: Array<{ request: ServerRequest; acceptSession: unknown; cancel: unknown }> = [
const requests: { request: ServerRequest; acceptSession: unknown; cancel: unknown }[] = [
{
request: {
id: 3,

View file

@ -57,7 +57,7 @@ function appFixture(options: {
activePath?: string;
linkDestination?: TFile | null;
getFirstLinkpathDest?: (target: string, sourcePath: string) => TFile | null;
markdownFiles?: Array<{ basename: string; path: string; stat: { mtime: number } }>;
markdownFiles?: { basename: string; path: string; stat: { mtime: number } }[];
abstractFiles?: Map<string, TFile>;
}): App {
return {

View file

@ -67,7 +67,7 @@ describe("thread naming", () => {
});
it("scans older thread pages until it finds a usable naming context", async () => {
const calls: Array<{ cursor: string | null; limit: number; sortDirection: string }> = [];
const calls: { cursor: string | null; limit: number; sortDirection: string }[] = [];
const context = await findThreadNamingContext({
threadId: "thread",
pageLimit: 2,

View file

@ -90,7 +90,13 @@ export function installObsidianDomShims(): void {
});
}
export function topLevelDetailsSummaries(element: HTMLElement): Array<string | null> {
function nodeConstructor(): typeof Node {
const defaultView = document.defaultView;
if (defaultView === null) throw new Error("Expected document.defaultView to install Obsidian DOM helpers.");
return (globalThis as typeof globalThis & { Node?: typeof Node }).Node ?? defaultView.Node;
}
export function topLevelDetailsSummaries(element: HTMLElement): (string | null)[] {
const candidates = [element, ...element.children];
return candidates
.filter((child): child is HTMLDetailsElement => child instanceof HTMLDetailsElement)