biome style/useNodeAssertStrict
labelled safe
Analysis Nemotron 3 Super
Flags imports of 'node:assert' to recommend using 'node:assert/strict' instead.
Fix: Replaces the module specifier 'node:assert' with 'node:assert/strict' in import or require statements while preserving the import kind (Namespace, Default, Named, etc.) and all syntactic structure except the string literal value.
12 hazards
- If the code relies on non-strict assertion behavior (e.g., `assert.ok(0, 0)` being treated as truthy), switching to strict mode may cause assertions to throw where they previously did not, altering control flow.
- If the imported `assert` is reassigned to a variable used in dynamic import expressions (e.g., `import(`${assert}`)`), changing the source string could break module resolution if the bundler or runtime depends on the literal value.
- If the import statement contains trailing or inline comments (e.g., `import * as assert from "node:assert" /* reason */;`), the autofix may drop or misplace them depending on the tool's comment handling.
- If the module specifier is constructed via concatenation (e.g., `import * as assert from "node:" + "assert"`), the rule does not fire, but if it did fire incorrectly, the fix would break because it assumes a literal string.
- If the code uses `assert` as a namespace object and expects non-strict methods like `assert.equal` to coexist with strict ones, the strict module may lack certain legacy aliases, causing runtime errors.
- If the import is wrapped in a conditional block (e.g., `if (true) { import * as assert from "node:assert"; }`), the fix preserves the block but changing the module may affect runtime behavior if the conditional guards side effects.
- If the import is used for its side effects only and the binding is unused (e.g., `import "node:assert"`), the rule does not flag it, but if misapplied, changing the string could fail to load the module if `node:assert/strict` has different side effects.
- If the codebase uses a custom module resolver or plugin that treats `node:assert` and `node:assert/strict` differently (e.g., for mocking), the rewrite could bypass intended mocks or aliases.
- If the import occurs in a file that is both ES module and CommonJS transpiled (e.g., via Babel), the rewrite may produce inconsistent output depending on the target format.
- If the assert import is reexported (e.g., `export * from "node:assert"`), changing the source may alter the reexported API surface if the strict module omits certain exports.
- If the code depends on the exact string "node:assert" appearing in stack traces or error messages (e.g., via `new Error().stack`), changing the import source may affect diagnostic output.
- If the import is part of a sequence where evaluation order matters (e.g., `import * as assert from "node:assert"; var x = assert.enabled;`), the fix preserves order but if `node:assert/strict` initializes differently, it could change timing.
Findings
| program | oracle | label | judge | status | summary |
|---|---|---|---|---|---|
| r1-p008 | fix-changes-behavior | labelled safe | intended-change · low | related | The rule intentionally changes the import from `node:assert` to `node:assert/strict` to enable stricter assertions. The observed difference in error messages (… |
Programs
| id | result | title | hazard |
|---|---|---|---|
| r1-p001 | fix ok | Non-strict vs strict equality | If the code relies on non-strict assertion behavior (e.g., `assert.ok(0, 0)` being treated as truthy), switching to strict mode may cause assertions to throw where they previously did not, altering co |
| r1-p002 | fix ok | Temporal dead zone interaction | temporal dead zone after code is hoisted or reordered |
| r1-p003 | fix ok | Comment preservation hazard | comments attached to the removed or moved code |
| r1-p004 | fix ok | Arguments and parameters interaction | arguments object, function.length, default parameters, rest parameters |
| r1-p006 | fix ok | Class field initialization | class fields, static blocks, private names, super calls |
| r1-p007 | fix ok | Namespace object usage | If the code uses `assert` as a namespace object and expects non-strict methods like `assert.equal` to coexist with strict ones, the strict module may lack certain legacy aliases, causing runtime error |
| r1-p008 | fix-changes-behavior | Getter/setter side effects | getters, setters and Object.defineProperty side effects |
| r2-p002 | silent | Concatenated Module Specifier Near-Miss | If the module specifier is constructed via concatenation (e.g., `import * as assert from "node:" + "assert"`), the rule does not fire, but if it did fire incorrectly, the fix would break because it as |
Sources
r1-p001 · Non-strict vs strict equality
1import * as assert from "node:assert";
2let x = 0;
3try {
4 assert.ok(x == 0);
5 console.log('non-strict ok');
6} catch(e) {
7 console.log(e.name + ': ' + e.message);
8}
9try {
10 assert.deepEqual([], []);
11 console.log('deepEqual ok');
12} catch(e) {
13 console.log(e.name + ': ' + e.message);
14}
--- orig.js 2026-10-17 17:03:41.465123888 -0400 +++ fixed.js 2026-10-17 17:03:41.774127446 -0400 @@ -1,4 +1,4 @@ -import * as assert from "node:assert"; +import * as assert from "node:assert/strict"; let x = 0; try { assert.ok(x == 0);
non-strict ok deepEqual ok
r1-p002 · Temporal dead zone interaction
1function f() {
2 try {
3 return assert.ok(true);
4 } catch(e) {
5 return 'caught';
6 }
7}
8const result = f();
9console.log(result);
10import * as assert from "node:assert";
--- orig.js 2026-10-17 17:03:41.939129347 -0400 +++ fixed.js 2026-10-17 17:03:42.216132535 -0400 @@ -7,4 +7,4 @@ } const result = f(); console.log(result); -import * as assert from "node:assert"; +import * as assert from "node:assert/strict";
undefined
r1-p003 · Comment preservation hazard
1/* eslint-disable */
2import /* keep this comment */ * as assert from "node:assert";
3console.log(typeof assert);
4// another comment
--- orig.js 2026-10-17 17:03:42.377134388 -0400 +++ fixed.js 2026-10-17 17:03:42.635137358 -0400 @@ -1,4 +1,4 @@ /* eslint-disable */ -import /* keep this comment */ * as assert from "node:assert"; +import /* keep this comment */ * as assert from "node:assert/strict"; console.log(typeof assert); // another comment
object
r1-p004 · Arguments and parameters interaction
1function g(a, b = assert.ok(true) || 10, ...rest) {
2 console.log(b, rest.length);
3}
4g(1);
5import * as assert from "node:assert";
--- orig.js 2026-10-17 17:03:42.798139234 -0400 +++ fixed.js 2026-10-17 17:03:43.098142687 -0400 @@ -2,4 +2,4 @@ console.log(b, rest.length); } g(1); -import * as assert from "node:assert"; +import * as assert from "node:assert/strict";
10 0
r1-p006 · Class field initialization
1class C {
2 static x = assert.ok(true) && 1;
3 y = assert.equal(1, 1) && 2;
4}
5console.log(C.x, new C().y);
6import * as assert from "node:assert";
--- orig.js 2026-10-17 17:03:43.279144770 -0400 +++ fixed.js 2026-10-17 17:03:43.559147992 -0400 @@ -3,4 +3,4 @@ y = assert.equal(1, 1) && 2; } console.log(C.x, new C().y); -import * as assert from "node:assert"; +import * as assert from "node:assert/strict";
undefined undefined
r1-p007 · Namespace object usage
1import * as assert from "node:assert";
2console.assert(typeof assert.equal === 'function');
3try {
4 assert.equal(1, 1);
5 console.log('equal worked');
6} catch(e) {
7 console.log(e.name + ': ' + e.message);
8}
--- orig.js 2026-10-17 17:03:43.740150075 -0400 +++ fixed.js 2026-10-17 17:03:44.025153354 -0400 @@ -1,4 +1,4 @@ -import * as assert from "node:assert"; +import * as assert from "node:assert/strict"; console.assert(typeof assert.equal === 'function'); try { assert.equal(1, 1);
equal worked
r1-p008 · Getter/setter side effects
1const obj = {};
2Object.defineProperty(obj, 'prop', {
3 get() { return assert.ok(true) && 42; },
4 set(v) { assert.equal(v, 42); }
5});
6console.log(obj.prop);
7obj.prop = 99;
8import * as assert from "node:assert";
--- orig.js 2026-10-17 17:03:44.202155390 -0400 +++ fixed.js 2026-10-17 17:03:44.480158588 -0400 @@ -5,4 +5,4 @@ }); console.log(obj.prop); obj.prop = 99; -import * as assert from "node:assert"; +import * as assert from "node:assert/strict";
undefined
r2-p002 · Concatenated Module Specifier Near-Miss
1const mod = 'node:' + 'assert';
2const assert = require(mod);
3try {
4 assert.ok(0, 0);
5} catch (e) {
6 console.log(e.name, e.message);
7}