chore(qa): Final Wave cleanup — resolve lint findings from F2 review

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 <noreply@anthropic.com>
This commit is contained in:
emil
2026-05-15 23:33:57 +03:00
co-authored by Claude Opus 4.7
parent 701398f627
commit 2f7453e571
15 changed files with 21 additions and 58 deletions
+4
View File
@@ -37,11 +37,15 @@ function mockRequest(
} as unknown as Request;
}
// vi.mock factories are hoisted, so refs they read must use var (not let/const)
// to be visible at hoist time without ReferenceError.
/* eslint-disable no-var */
var mockOpenRouterNPC = vi.fn();
var mockKimiNPC = vi.fn();
var mockSearchMonsters = vi.fn();
var mockCheckRateLimit = vi.fn();
var mockIncrementCounter = vi.fn();
/* eslint-enable no-var */
vi.mock("@/lib/ai/openrouter", () => ({
generateNPC: (...args: unknown[]) => mockOpenRouterNPC(...args),
+1 -1
View File
@@ -96,7 +96,7 @@ function createMockDb() {
};
}
let mockDb = createMockDb();
const mockDb = createMockDb();
vi.mock("drizzle-orm", async (importOriginal) => {
const actual = await importOriginal<typeof import("drizzle-orm")>();
+1 -13
View File
@@ -12,18 +12,6 @@ const mockUser = {
createdAt: new Date("2024-01-01"),
};
const mockUser2 = {
id: 2,
vkId: null,
yandexId: null,
email: null,
name: "Other User",
avatar: null,
tier: "free" as const,
boostyVerifiedAt: null,
createdAt: new Date("2024-01-01"),
};
function mockRequest(
url: string,
origin: string,
@@ -132,7 +120,7 @@ function createMockDb() {
};
}
let mockDb = createMockDb();
const mockDb = createMockDb();
vi.mock("drizzle-orm", async (importOriginal) => {
const actual = await importOriginal<typeof import("drizzle-orm")>();
+1 -13
View File
@@ -12,18 +12,6 @@ const mockUser = {
createdAt: new Date("2024-01-01"),
};
const mockUser2 = {
id: 2,
vkId: null,
yandexId: null,
email: null,
name: "Other User",
avatar: null,
tier: "free" as const,
boostyVerifiedAt: null,
createdAt: new Date("2024-01-01"),
};
function mockRequest(
url: string,
origin: string,
@@ -132,7 +120,7 @@ function createMockDb() {
};
}
let mockDb = createMockDb();
const mockDb = createMockDb();
vi.mock("drizzle-orm", async (importOriginal) => {
const actual = await importOriginal<typeof import("drizzle-orm")>();
+2
View File
@@ -5,6 +5,7 @@ import type { Monster, Spell } from "../src/lib/open5e/client";
// If a listed key is missing from the interface, TypeScript will error at compile time.
type AssertKeys<T, K extends keyof T> = K;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type _MonsterHasAllFields = AssertKeys<
Monster,
| "name"
@@ -34,6 +35,7 @@ type _MonsterHasAllFields = AssertKeys<
| "condition_immunities"
>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type _SpellHasAllFields = AssertKeys<
Spell,
| "name"
+1 -1
View File
@@ -77,7 +77,7 @@ function createMockDb() {
};
}
let mockDb = createMockDb();
const mockDb = createMockDb();
vi.mock("drizzle-orm", async (importOriginal) => {
const actual = await importOriginal<typeof import("drizzle-orm")>();
+1 -2
View File
@@ -3,7 +3,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
const mockPostMessage = vi.fn();
const mockAddEventListener = vi.fn();
function MockBroadcastChannel(this: unknown, _name: string) {
function MockBroadcastChannel(this: unknown) {
return {
postMessage: mockPostMessage,
addEventListener: mockAddEventListener,
@@ -75,7 +75,6 @@ describe("translation service", () => {
global.fetch = mockFetch as unknown as typeof fetch;
const {
getCachedTranslation,
setCachedTranslation,
fetchTranslation,
clearTranslationCache,