Repository navigation
chore(test): migrate node:assert/strict to plain node:assert; lint-enforce via oxlint (#1555) - #1558
Conversation
…force via oxlint AGENTS.md documents plain node:assert as house style and explicitly rules out node:assert/strict, but nothing enforced it and 210 test files (unitTests, integrationTests, benchmarks) violated the convention. Add oxlint's no-restricted-imports rule to reject node:assert/strict and assert/strict imports, then migrate all existing usages so the rule is green. The migration swaps only the import/require specifier (node:assert/strict -> node:assert); call sites are untouched. This is safe because strict->loose only ever weakens an assertion, so no currently-green test can turn red, and the loosened assert.equal/deepEqual semantics are the intended house-style outcome. Three integrationTests files (cert-key-reload, cert-reload, replay-stress) destructure `equal` from assert/strict, which silently becomes the loose alias after the swap — flagged for reviewer awareness, not changed further, since rewriting call sites to strictEqual would contradict the house style. Closes #1555 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1. README template still documents the banned importFile: What: The PR adds a Why it matters: Any contributor who follows this README to write a new integration test will immediately hit a lint error in CI. AGENTS.md and the lint rule point in the same direction; the README template points the opposite direction. Suggested fix: Line 93 — change: to: Line 112 — change: import { strictEqual } from 'node:assert/strict';to e.g.: import assert from 'node:assert';(then The two follow-on commits ( |
There was a problem hiding this comment.
Code Review
This pull request replaces imports of node:assert/strict and assert/strict with plain node:assert and assert across the test suite, aligning with the project's house style. It also adds a lint rule in .oxlintrc.json to enforce this restriction and updates the AGENTS.md documentation. The review feedback highlights that in several files (cert-key-reload.test.ts, cert-reload.test.ts, and replay-stress.test.ts), changing the import to plain node:assert inadvertently changes the behavior of equal from strict equality to loose equality. It is recommended to alias strictEqual as equal in these imports to preserve strict semantics.
… strictEqual-as-equal alias (gemini review)
Three security/stress integration tests destructured `equal` from
node:assert/strict, where it aliased strictEqual (===). After the import
migration to plain node:assert, `equal` would silently become the loose
== version. Preserve strict semantics without touching any call sites by
aliasing: `import { ok, strictEqual as equal } from 'node:assert'`.
This is the documented strict escape hatch in AGENTS.md and does not
conflict with the no-restricted-imports lint rule, which only bans the
node:assert/strict path.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…iles
The initial migration ("strict→loose only weakens") was wrong for negative
assertions. node:assert/strict makes notEqual an alias for notStrictEqual
(!==); plain node:assert's notEqual uses loose !=. So
assert.notEqual(null, undefined) passes under strict but throws under
loose, which is exactly what broke the northwind LEFT OUTER JOIN
integration tests: unmatched columns come back as null, and tests asserted
notEqual(row[key], undefined).
Fix: rename 37 call sites across 17 files from assert.notEqual →
assert.notStrictEqual and assert.notDeepEqual → assert.notDeepStrictEqual.
All are method-style calls on the default assert namespace; no import
changes needed. This restores the exact behavior those files had under
node:assert/strict.
Positive assertions (equal, deepEqual) are unaffected — loosening those
is the intended house-style outcome.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
kriszyp
left a comment
There was a problem hiding this comment.
Reviewed via Claude review-queue — semantics-preserving node:assert/strict->plain migration, verified full-tree grep clean and negative-assertion renames diff 1:1 to strict variants. CI green. LGTM.
Summary
Enforces the AGENTS.md test-style convention — plain `node:assert`, never `node:assert/strict` — mechanically and permanently:
No non-test source file imported `/strict` anywhere in the repo (full-tree grep across all extensions).
Why
The convention was documented but unenforced, and the codebase violated it ~8:1 — so the AI reviewer re-raised it as a non-blocking nit on every affected PR (most recently #1106) with no path to resolution.
Important correction from initial premise: the original commit message said "strict→loose only ever weakens an assertion, so no currently-green test can turn red." That is wrong for negative assertions. `node:assert/strict` makes `notEqual` an alias for `notStrictEqual` (`!==`); plain `node:assert`'s `notEqual` uses loose `!=`. So `assert.notEqual(null, undefined)` passes under strict (`null !== undefined`) but throws under loose (`null != undefined` is false). This is exactly why northwind LEFT OUTER JOIN integration tests failed on all runtimes: unmatched columns come back as `null`, and the tests asserted `notEqual(row[key], undefined)`. The fix — renaming those 37 call sites to `notStrictEqual` / `notDeepStrictEqual` — is behavior-preserving (restores what they were under `/strict`). Positive assertions (`equal`, `deepEqual`) are unaffected.
Where to look
Verification
Closes #1555
Generated by an LLM (Claude Sonnet 5, orchestrated via Claude Code).
🤖 Generated with Claude Code