assertStrict
Prefer strict assertion mode from Node.js for better error messages and behavior.
✅ This rule is included in the node logical preset.
In strict assertion mode, non-strict methods like deepEqual() behave like their strict counterparts (deepStrictEqual()).
Strict mode provides better error messages with diffs and more reliable equality checks, reducing the risk of false positives in tests.
Examples
Section titled “Examples”import assert from "assert";
import assert from "node:assert";
import { deepEqual } from "node:assert";import assert from "assert/strict";
import assert from "node:assert/strict";
import { strict as assert } from "node:assert";
import { strict } from "node:assert";Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you specifically need the non-strict behavior of assertion methods (for example, when testing legacy code that relies on coercive equality), you might choose not to enable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
useNodeAssertStrict
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.