From 7a49ff989660619c3d3bcb468ae8b9e7f177cf73 Mon Sep 17 00:00:00 2001 From: Richard R Date: Thu, 21 May 2026 21:44:58 -0600 Subject: [PATCH] chore(lint): fix eslint violations in worker config and e2e tests --- compute/worker/src/server.ts | 4 ++-- empty-module.ts | 4 +++- next.config.ts | 3 +-- tests/folders.spec.ts | 4 ++-- tests/navigation.spec.ts | 8 ++++---- tests/upload.spec.ts | 20 ++++++++++++++++---- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/compute/worker/src/server.ts b/compute/worker/src/server.ts index 14ce0d7..176304f 100644 --- a/compute/worker/src/server.ts +++ b/compute/worker/src/server.ts @@ -20,7 +20,7 @@ import { type JetStreamManager, type JsMsg, } from '@nats-io/jetstream'; -import { Kvm, type KV } from '@nats-io/kv'; +import { Kvm } from '@nats-io/kv'; import { ensureComputeModels, runPdfLayoutFromPdfBuffer, @@ -437,7 +437,7 @@ async function main(): Promise { Math.max(30 * 60_000, Math.max(whisperTimeoutMs, pdfTimeoutMs) * 4), ); - const connectOpts: any = { servers: natsUrl }; + const connectOpts: Parameters[0] = { servers: natsUrl }; const natsCreds = process.env.NATS_CREDS?.trim(); const natsCredsFile = process.env.NATS_CREDS_FILE?.trim(); diff --git a/empty-module.ts b/empty-module.ts index 7c645e4..de5f48e 100644 --- a/empty-module.ts +++ b/empty-module.ts @@ -1 +1,3 @@ -export default {}; \ No newline at end of file +const emptyModule = {}; + +export default emptyModule; diff --git a/next.config.ts b/next.config.ts index 3192309..3537f43 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,5 +1,6 @@ import type { NextConfig } from "next"; import path from "node:path"; +import { DefinePlugin } from "webpack"; const securityHeaders = [ { key: 'X-Content-Type-Options', value: 'nosniff' }, @@ -78,8 +79,6 @@ const nextConfig: NextConfig = { }, webpack: (config, { isServer }) => { if (isServer) { - // Use runtime require to avoid adding an explicit webpack TS dependency. - const { DefinePlugin } = require('webpack') as { DefinePlugin: new (defs: Record) => unknown }; config.plugins = config.plugins || []; config.plugins.push( new DefinePlugin({ diff --git a/tests/folders.spec.ts b/tests/folders.spec.ts index b1c413d..3f9e0fb 100644 --- a/tests/folders.spec.ts +++ b/tests/folders.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from '@playwright/test'; +import { test, expect, type Page } from '@playwright/test'; import { setupTest, uploadFiles, ensureDocumentsListed, waitForDocumentListHintPersist, dispatchHtml5DragAndDrop } from './helpers'; test.describe('Document folders and hint persistence', () => { @@ -7,7 +7,7 @@ test.describe('Document folders and hint persistence', () => { }); // Utility to get the draggable row for a given filename (by link) - const rowFor = (page: any, fileName: string) => { + const rowFor = (page: Page, fileName: string) => { const link = page.getByRole('link', { name: new RegExp(fileName, 'i') }).first(); // The draggable attribute lives on the row container ancestor return link.locator('xpath=ancestor::*[@draggable="true"][1]'); diff --git a/tests/navigation.spec.ts b/tests/navigation.spec.ts index ddcf015..173a0c1 100644 --- a/tests/navigation.spec.ts +++ b/tests/navigation.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from '@playwright/test'; +import { test, expect, type Page } from '@playwright/test'; import { setupTest, uploadFiles, @@ -11,7 +11,7 @@ import { } from './helpers'; // Single-spec helpers kept local to avoid cluttering shared helpers: -async function navigateToPdfPageViaNavigator(page: any, targetPage: number) { +async function navigateToPdfPageViaNavigator(page: Page, targetPage: number) { // Navigator popover shows "X / Y" const navTrigger = page.getByRole('button', { name: /\d+\s*\/\s*\d+/ }); await expect(navTrigger).toBeVisible({ timeout: 10000 }); @@ -23,11 +23,11 @@ async function navigateToPdfPageViaNavigator(page: any, targetPage: number) { await input.press('Enter'); } -async function countRenderedPdfPages(page: any): Promise { +async function countRenderedPdfPages(page: Page): Promise { return await page.locator('.react-pdf__Page').count(); } -async function triggerViewportResize(page: any, width: number, height: number) { +async function triggerViewportResize(page: Page, width: number, height: number) { await page.setViewportSize({ width, height }); } diff --git a/tests/upload.spec.ts b/tests/upload.spec.ts index b95e7cd..afcdef7 100644 --- a/tests/upload.spec.ts +++ b/tests/upload.spec.ts @@ -1,6 +1,15 @@ import { test, expect } from '@playwright/test'; import { uploadFile, uploadAndDisplay, setupTest, expectDocumentListed, uploadFiles, ensureDocumentsListed, clickDocumentLink, expectViewerForFile } from './helpers'; +interface HtmlDocumentRow { + id?: string; + data?: string; +} + +type HashCheckResult = + | { ok: true; storedId: string; computedId: string } + | { ok: false; reason: 'Missing stored html document' }; + test.describe('Document Upload Tests', () => { test.beforeEach(async ({ page }, testInfo) => { await setupTest(page, testInfo); @@ -25,7 +34,7 @@ test.describe('Document Upload Tests', () => { await uploadFile(page, 'sample.txt'); await expectDocumentListed(page, 'sample.txt'); - const result = await page.evaluate(async () => { + const result = await page.evaluate(async () => { const idb = await new Promise((resolve, reject) => { const request = indexedDB.open('openreader-db'); request.onerror = () => reject(request.error); @@ -33,12 +42,12 @@ test.describe('Document Upload Tests', () => { }); try { - const docs = await new Promise((resolve, reject) => { + const docs = await new Promise((resolve, reject) => { const tx = idb.transaction('html-documents', 'readonly'); const store = tx.objectStore('html-documents'); const request = store.getAll(); request.onerror = () => reject(request.error); - request.onsuccess = () => resolve(request.result as any[]); + request.onsuccess = () => resolve(request.result as HtmlDocumentRow[]); }); if (!docs[0]?.data || !docs[0]?.id) { @@ -57,7 +66,10 @@ test.describe('Document Upload Tests', () => { } }); - expect(result.ok, `Expected storedId=${(result as any).storedId} computedId=${(result as any).computedId}`).toBeTruthy(); + const detail = result.ok + ? `Expected storedId=${result.storedId} computedId=${result.computedId}` + : `Expected valid stored html document but got reason=${result.reason}`; + expect(result.ok, detail).toBeTruthy(); }); test('uploads and converts a DOCX document', async ({ page }) => {