From 2f7453e571ad6cb499eac4669473ddf1d25b48aa Mon Sep 17 00:00:00 2001 From: emil Date: Fri, 15 May 2026 23:33:57 +0300 Subject: [PATCH] =?UTF-8?q?chore(qa):=20Final=20Wave=20cleanup=20=E2=80=94?= =?UTF-8?q?=20resolve=20lint=20findings=20from=20F2=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Production code (all findings cleared): - GenerationHistory: drop unused fetchProHistory(userId) param, change let activeId to const - InitiativeTracker: remove write-only currentSessionName state - NotesPanel: remove unused isLoading flag - Open5eReference: drop unused getCachedTranslation/setCachedTranslation imports; use fetchTranslation result directly instead of re-lookup - ai/openrouter.ts: drop unused z + Monster imports; attach cause to rethrown AbortError - ai/kimi.ts: drop unused z import - api/dm/ai/generate.ts: annotate best-effort counter increment catch - api/dm/ai/history.ts: drop unused sql import Test files (trivial fixes; ~70 mock-related `as any` errors remain as pre-existing tech debt across api test mocks): - translation-client: drop unused MockBroadcastChannel _name param and unused getCachedTranslation destructure - open5e-types: eslint-disable for the intentional type-test aliases - {notes,initiative}-api: remove unused mockUser2 placeholder - {notes,initiative,translate,history}-api: let mockDb -> const mockDb - ai-generate-api: wrap deliberate `var` mock decls in eslint-disable with comment explaining vi.mock hoisting requirement Verification: tsc 0 errors, vitest 339/339, lint 81 -> 70 errors (production code fully clean; remaining errors are test-mock as-any patterns from Waves 5-6). Co-Authored-By: Claude Opus 4.7 --- src/components/dm/GenerationHistory.astro | 6 +++--- src/components/dm/InitiativeTracker.astro | 5 ----- src/components/dm/NotesPanel.astro | 5 ----- src/components/dm/Open5eReference.astro | 12 +++--------- src/lib/ai/kimi.ts | 1 - src/lib/ai/openrouter.ts | 6 ++---- src/pages/api/dm/ai/generate.ts | 1 + src/pages/api/dm/ai/history.ts | 2 +- tests/ai-generate-api.test.ts | 4 ++++ tests/history-api.test.ts | 2 +- tests/initiative-api.test.ts | 14 +------------- tests/notes-api.test.ts | 14 +------------- tests/open5e-types.test.ts | 2 ++ tests/translate-api.test.ts | 2 +- tests/translation-client.test.ts | 3 +-- 15 files changed, 21 insertions(+), 58 deletions(-) diff --git a/src/components/dm/GenerationHistory.astro b/src/components/dm/GenerationHistory.astro index 3e67369..35c77b6 100644 --- a/src/components/dm/GenerationHistory.astro +++ b/src/components/dm/GenerationHistory.astro @@ -251,7 +251,7 @@ const { tier, userId } = Astro.props; ); } - async function fetchProHistory(userId: number): Promise { + async function fetchProHistory(): Promise { const response = await fetch(`/api/dm/ai/history?limit=${MAX_HISTORY}`); if (!response.ok) { if (response.status === 401) { @@ -269,7 +269,7 @@ const { tier, userId } = Astro.props; const loadingEl = container.querySelector('#history-loading'); let items: HistoryItem[] = []; - let activeId: number | null = null; + const activeId: number | null = null; function showLoading() { loadingEl?.classList.remove('hidden'); @@ -283,7 +283,7 @@ const { tier, userId } = Astro.props; if (tier === 'pro' && userId) { showLoading(); try { - items = await fetchProHistory(userId); + items = await fetchProHistory(); } catch { items = []; } finally { diff --git a/src/components/dm/InitiativeTracker.astro b/src/components/dm/InitiativeTracker.astro index 1d978e0..77ba27b 100644 --- a/src/components/dm/InitiativeTracker.astro +++ b/src/components/dm/InitiativeTracker.astro @@ -184,7 +184,6 @@ const { tier = 'free', userId } = Astro.props; let activeIndex = 0; let currentSessionId: number | null = null; - let currentSessionName = ''; interface CombatantData { id: string; @@ -559,7 +558,6 @@ const { tier = 'free', userId } = Astro.props; saveCombatants(session.participants); activeIndex = 0; currentSessionId = session.id; - currentSessionName = session.name; if (sessionNameInput) sessionNameInput.value = session.name; updateVisibility(); renderList(); @@ -578,7 +576,6 @@ const { tier = 'free', userId } = Astro.props; const result = await apiSaveSession(name, participants, currentSessionId ?? undefined); if (result) { currentSessionId = result.id; - currentSessionName = result.name; if (sessionNameInput) sessionNameInput.value = result.name; showSessionStatus('Сессия сохранена'); renderSessionList(); @@ -589,7 +586,6 @@ const { tier = 'free', userId } = Astro.props; async function handleNewSession() { currentSessionId = null; - currentSessionName = ''; if (sessionNameInput) sessionNameInput.value = ''; clearAll(); showSessionStatus('Новая сессия'); @@ -602,7 +598,6 @@ const { tier = 'free', userId } = Astro.props; if (ok) { if (currentSessionId === id) { currentSessionId = null; - currentSessionName = ''; if (sessionNameInput) sessionNameInput.value = ''; } renderSessionList(); diff --git a/src/components/dm/NotesPanel.astro b/src/components/dm/NotesPanel.astro index 9f1379e..9e4bda6 100644 --- a/src/components/dm/NotesPanel.astro +++ b/src/components/dm/NotesPanel.astro @@ -49,7 +49,6 @@ const { tier = 'free', userId } = Astro.props; let debounceTimer: ReturnType | null = null; let hideIndicatorTimer: ReturnType | null = null; let dbNoteId: number | null = null; - let isLoading = false; function formatTime(date: Date): string { return date.toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' }); @@ -123,23 +122,19 @@ const { tier = 'free', userId } = Astro.props; async function loadSavedNotes() { if (isPro) { - isLoading = true; const note = await loadDbNotes(); if (note) { dbNoteId = note.id; textarea.value = note.content ?? ''; } else { - // Try to create a new note if none exists const newId = await createDbNote(''); if (newId) { dbNoteId = newId; textarea.value = ''; } else { - // Fallback to localStorage if DB is unavailable textarea.value = loadNotes(); } } - isLoading = false; } else { const saved = loadNotes(); textarea.value = saved; diff --git a/src/components/dm/Open5eReference.astro b/src/components/dm/Open5eReference.astro index 5522e66..a54fd8a 100644 --- a/src/components/dm/Open5eReference.astro +++ b/src/components/dm/Open5eReference.astro @@ -171,11 +171,7 @@ import DmButton from "./DmButton.astro";