From 86f487d0ef7afc9839c7c7e8027547867f467593 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 4 Apr 2026 23:06:43 +0200 Subject: [PATCH] fix(image-pipeline): apply wasm/webgl lint hygiene cleanups --- lib/image-pipeline/backend/wasm/wasm-loader.ts | 4 ++-- tests/image-pipeline/wasm-backend.test.ts | 6 +++--- tests/image-pipeline/webgl-backend-poc.test.ts | 13 ++++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/image-pipeline/backend/wasm/wasm-loader.ts b/lib/image-pipeline/backend/wasm/wasm-loader.ts index 5bf6a04..9522e46 100644 --- a/lib/image-pipeline/backend/wasm/wasm-loader.ts +++ b/lib/image-pipeline/backend/wasm/wasm-loader.ts @@ -25,8 +25,8 @@ function assertWasmSimdRuntimeSupport(): void { throw new Error("WebAssembly SIMD is unavailable."); } - const module = new WebAssembly.Module(WASM_SIMD_PROBE_MODULE); - void new WebAssembly.Instance(module); + const wasmModule = new WebAssembly.Module(WASM_SIMD_PROBE_MODULE); + void new WebAssembly.Instance(wasmModule); } export function loadWasmKernelModule(): WasmKernelModule { diff --git a/tests/image-pipeline/wasm-backend.test.ts b/tests/image-pipeline/wasm-backend.test.ts index fbe3afd..2eea6c7 100644 --- a/tests/image-pipeline/wasm-backend.test.ts +++ b/tests/image-pipeline/wasm-backend.test.ts @@ -326,13 +326,13 @@ describe("wasm backend fallback behavior", () => { vi.stubGlobal("SharedArrayBuffer", undefined); vi.stubGlobal("Worker", undefined); - const module: WasmKernelModule = { + const wasmModule: WasmKernelModule = { applyPreviewStep: vi.fn(), applyFullPipeline: vi.fn(), }; const backend = createWasmSimdBackend({ - loadModule: () => module, + loadModule: () => wasmModule, }); expect(() => { @@ -343,6 +343,6 @@ describe("wasm backend fallback behavior", () => { height: 1, }); }).not.toThrow(); - expect(module.applyPreviewStep).toHaveBeenCalledTimes(1); + expect(wasmModule.applyPreviewStep).toHaveBeenCalledTimes(1); }); }); diff --git a/tests/image-pipeline/webgl-backend-poc.test.ts b/tests/image-pipeline/webgl-backend-poc.test.ts index c982f6f..9b089a5 100644 --- a/tests/image-pipeline/webgl-backend-poc.test.ts +++ b/tests/image-pipeline/webgl-backend-poc.test.ts @@ -380,8 +380,9 @@ describe("webgl backend poc", () => { height: 1, }); - const sourceTexture = (fakeGl.createTexture as any).mock.results[0]?.value; - const outputTexture = (fakeGl.createTexture as any).mock.results[1]?.value; + const createTextureMock = vi.mocked(fakeGl.createTexture); + const sourceTexture = createTextureMock.mock.results[0]?.value; + const outputTexture = createTextureMock.mock.results[1]?.value; expect(sourceTexture).toBeTruthy(); expect(outputTexture).toBeTruthy(); @@ -393,9 +394,11 @@ describe("webgl backend poc", () => { 0, ); - const bindTextureCalls = (fakeGl.bindTexture as any).mock.calls as Array<[number, unknown]>; - const bindTextureOrder = (fakeGl.bindTexture as any).mock.invocationCallOrder as number[]; - const drawOrder = (fakeGl.drawArrays as any).mock.invocationCallOrder[0] as number; + const bindTextureMock = vi.mocked(fakeGl.bindTexture); + const drawArraysMock = vi.mocked(fakeGl.drawArrays); + const bindTextureCalls = bindTextureMock.mock.calls; + const bindTextureOrder = bindTextureMock.mock.invocationCallOrder; + const drawOrder = drawArraysMock.mock.invocationCallOrder[0] ?? Number.POSITIVE_INFINITY; const lastBindBeforeDrawIndex = bindTextureOrder .map((callOrder, index) => ({ callOrder, index })) .filter(({ callOrder, index }) => callOrder < drawOrder && bindTextureCalls[index]?.[0] === fakeGl.TEXTURE_2D)