From 654aa421e96825d943e2241b8a5ffc3fd945d5ae Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Wed, 6 May 2026 02:31:07 +0300 Subject: [PATCH] chore(lint): reduce test rule exceptions - Re-enable duplicate imports, radix, prefer-const, nested ternary, and silent catch checks in tests - Drop the redundant spec-file override covered by the broader test override - Fix the remaining test offenders surfaced by the stricter rules --- oxlint.json | 17 +---------------- tests/e2e/perf/basic.spec.ts | 8 +++----- tests/engine/cli/eval.test.ts | 2 +- tests/engine/figma/api.test.ts | 4 +++- tests/engine/mutation.test.ts | 17 ++++++++--------- .../render/canvas/silhouette-autopsy.test.ts | 2 +- tests/engine/render/canvas/text.test.ts | 8 ++++++-- tests/engine/tools/ai-adapter.test.ts | 4 ++-- tests/engine/visual-inner-shadow-counter.ts | 6 ++++-- 9 files changed, 29 insertions(+), 39 deletions(-) diff --git a/oxlint.json b/oxlint.json index b51f9fb9f..d817ba1f6 100644 --- a/oxlint.json +++ b/oxlint.json @@ -165,18 +165,13 @@ "files": ["tests/**/*.ts", "tests/**/*.tsx"], "rules": { "typescript/no-non-null-assertion": "off", - "open-pencil/no-silent-catch": "off", "no-unused-vars": "off", "no-empty-function": "off", - "unicorn/no-nested-ternary": "off", "typescript/consistent-type-imports": "off", "open-pencil/no-inline-named-types": "off", "no-console": "off", "max-lines": "off", - "complexity": "off", - "radix": "off", - "prefer-const": "off", - "import/no-duplicates": "off" + "complexity": "off" } }, { @@ -234,16 +229,6 @@ "typescript/no-non-null-assertion": "error" } }, - { - "files": ["tests/**/*.spec.ts"], - "rules": { - "typescript/no-non-null-assertion": "off", - "open-pencil/no-silent-catch": "off", - "no-unused-vars": "off", - "no-empty-function": "off", - "unicorn/no-nested-ternary": "off" - } - }, { "files": ["scripts/**/*.ts"], "rules": { diff --git a/tests/e2e/perf/basic.spec.ts b/tests/e2e/perf/basic.spec.ts index 131e6cafa..de0b88d13 100644 --- a/tests/e2e/perf/basic.spec.ts +++ b/tests/e2e/perf/basic.spec.ts @@ -23,11 +23,9 @@ test.describe('Render performance', () => { const mod = i % 10 const isVector = mod === 0 const isEllipse = mod === 5 - const type = isVector - ? ('VECTOR' as const) - : isEllipse - ? ('ELLIPSE' as const) - : ('RECTANGLE' as const) + let type: 'VECTOR' | 'ELLIPSE' | 'RECTANGLE' = 'RECTANGLE' + if (isVector) type = 'VECTOR' + else if (isEllipse) type = 'ELLIPSE' const props: Record = { x: (i % cols) * 60, y: Math.floor(i / cols) * 60, diff --git a/tests/engine/cli/eval.test.ts b/tests/engine/cli/eval.test.ts index 11b92e28d..9c2c1c0e8 100644 --- a/tests/engine/cli/eval.test.ts +++ b/tests/engine/cli/eval.test.ts @@ -54,7 +54,7 @@ heavy('eval CLI', () => { 'return figma.root.children.length' ]) expect(exitCode).toBe(0) - const count = parseInt(stdout) + const count = parseInt(stdout, 10) expect(count).toBeGreaterThan(0) }) diff --git a/tests/engine/figma/api.test.ts b/tests/engine/figma/api.test.ts index c46ae03c4..23cf993d1 100644 --- a/tests/engine/figma/api.test.ts +++ b/tests/engine/figma/api.test.ts @@ -593,7 +593,9 @@ describe('FigmaAPI', () => { const fills = rect.fills as Fill[] try { fills[0].color.r = 0 - } catch {} + } catch (error) { + expect(error).toBeInstanceOf(TypeError) + } expect(rect.fills[0].color.r).toBe(1) }) }) diff --git a/tests/engine/mutation.test.ts b/tests/engine/mutation.test.ts index b2baec9b0..c3d4b74ad 100644 --- a/tests/engine/mutation.test.ts +++ b/tests/engine/mutation.test.ts @@ -1,19 +1,18 @@ import { describe, test, expect } from 'bun:test' import { + applyStyleToRange, + decodeVectorNetworkBlob, + encodeVectorNetworkBlob, + getStyleAt, + removeStyleFromRange, + SceneGraph, toggleBoldInRange, toggleItalicInRange, - applyStyleToRange, - removeStyleFromRange, - getStyleAt, - type StyleRun -} from '@open-pencil/core' -import { - encodeVectorNetworkBlob, - decodeVectorNetworkBlob, + UndoManager, + type StyleRun, type VectorNetwork } from '@open-pencil/core' -import { SceneGraph, UndoManager } from '@open-pencil/core' // --------------------------------------------------------------------------- // toggleBoldInRange — mutation coverage diff --git a/tests/engine/render/canvas/silhouette-autopsy.test.ts b/tests/engine/render/canvas/silhouette-autopsy.test.ts index e63623939..ee7ae9f64 100644 --- a/tests/engine/render/canvas/silhouette-autopsy.test.ts +++ b/tests/engine/render/canvas/silhouette-autopsy.test.ts @@ -356,7 +356,7 @@ describe('Doc 01/03 — Runtime Behavior Verification', () => { fontData.buffer.slice(fontData.byteOffset, fontData.byteOffset + fontData.byteLength) ) } catch { - // Font may not be available in headless — some text tests will be skipped + void fontPath } const surface = ck.MakeSurface(200, 200)! diff --git a/tests/engine/render/canvas/text.test.ts b/tests/engine/render/canvas/text.test.ts index 4b67ac437..cbdcc7b72 100644 --- a/tests/engine/render/canvas/text.test.ts +++ b/tests/engine/render/canvas/text.test.ts @@ -1,7 +1,11 @@ import { describe, test, expect, mock } from 'bun:test' -import { SceneGraph, SkiaRenderer as SkiaRendererClass } from '@open-pencil/core' -import { detectTextDirection, resolveTextDirection } from '@open-pencil/core' +import { + detectTextDirection, + resolveTextDirection, + SceneGraph, + SkiaRenderer as SkiaRendererClass +} from '@open-pencil/core' import { initCanvasKit } from '#cli/headless' import type { SkiaRenderer } from '#core/canvas/renderer' diff --git a/tests/engine/tools/ai-adapter.test.ts b/tests/engine/tools/ai-adapter.test.ts index c5687e98f..1cd5d2e18 100644 --- a/tests/engine/tools/ai-adapter.test.ts +++ b/tests/engine/tools/ai-adapter.test.ts @@ -136,8 +136,8 @@ describe('AI adapter', () => { const evalTool = adapterTool(tools, 'eval') try { await evalTool.execute({ code: 'throw new Error("test")' }) - } catch { - // expected + } catch (error) { + expect(error).toBeInstanceOf(Error) } expect(afterCalled).toBe(true) diff --git a/tests/engine/visual-inner-shadow-counter.ts b/tests/engine/visual-inner-shadow-counter.ts index 244d6d4d4..ff8047c9d 100644 --- a/tests/engine/visual-inner-shadow-counter.ts +++ b/tests/engine/visual-inner-shadow-counter.ts @@ -87,11 +87,13 @@ async function main() { // Scan the center line to find the 'O' boundaries // Background (Blue) | Left Stem (White/Shadow) | Counter (Blue) | Right Stem (White/Shadow) | Background (Blue) - let transitions = [] + const transitions = [] let lastColor = '' for (let x = 0; x < width; x++) { const p = getPixel(x, centerY) - const color = p[0] > 200 ? 'white' : p[2] > 200 ? 'blue' : 'black' + let color = 'black' + if (p[0] > 200) color = 'white' + else if (p[2] > 200) color = 'blue' if (color !== lastColor) { transitions.push({ x, color }) lastColor = color