Skip to content

refactor: fix unicorn/no-new-array and enable it in .oxlintrc.json - #72

Merged
bhouston merged 1 commit into
mainfrom
refactor/71-no-new-array-stage3
Sep 25, 2026
Merged

bhouston merged 1 commit into
mainfrom
refactor/71-no-new-array-stage3

Conversation

@bhouston

Copy link
Copy Markdown
Owner

Closes #71

Summary

Deferred from stage 1 (#68): unicorn/no-new-array was kept "off" because turning it on surfaced 10 pre-existing errors in pizHuffman.ts and b44Codec.test.ts.

  • Replaced new Array(n) with Array.from({ length: n }) at all 8 call sites in pizHuffman.ts and 2 in b44Codec.test.ts.
  • Added an explicit Array.from<number>({ length: n }) type argument at the two untyped call sites (hufTableBuffer, freq in hufUncompress) — new Array(n) without an annotation inferred any[], so removing it surfaced real tsc errors (arithmetic on possibly-unknown/null values) that needed the explicit type to keep compiling; behavior is unchanged since every one of these arrays is fully populated by index before being read elsewhere (the dense-vs-sparse difference between Array.from and new Array doesn't matter for direct index access).
  • .oxlintrc.json: flips unicorn/no-new-array to "error", now byte-identical to canonical alongside the other two tightened rules (already enabled since stage 1).

Validation

  • pnpm build, pnpm tsc, pnpm lint, pnpm exec oxfmt --check . pass
  • pnpm exec vitest run packages/hdrify/src/exr/b44Codec.test.ts (the touched test file): 8/8 pass
  • pnpm test --coverage (full suite): running; watching PR CI on dedicated runners for the authoritative result (local EXR-decode tests intermittently time out on this machine under load, as noted in chore: standardize CI/tooling to v2 canonical (stage 1) #68/build(deps): upgrade vitest to v5 #70)
  • node /path/to/standards/check-drift.mjs <repo>: clean, no exceptions remaining

Replace new Array(n) with Array.from({ length: n }) (adding an explicit
<number> type argument where TS previously inferred any[] from the
untyped new Array(n), to keep pizHuffman.ts's arithmetic on freq/
hufTableBuffer entries type-checking). Semantics are unchanged: every one
of these arrays is fully populated by index before being read (dense
Array.from vs. new Array's sparse holes doesn't matter here).

Flips unicorn/no-new-array to "error" in .oxlintrc.json, matching
canonical byte-for-byte alongside the other two tightened rules enabled
in stage 1.

Closes #71
@bhouston
bhouston merged commit 8f9940b into main Sep 25, 2026
2 checks passed
@bhouston
bhouston deleted the refactor/71-no-new-array-stage3 branch September 25, 2026 18:25
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/hdrify/src/exr/pizHuffman.ts 75.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: fix unicorn/no-new-array and enable tightened lint rules (stage 3)

2 participants