assertion-arguments
July 2, 2026 ยท View on GitHub
๐ Enforce the correct number of arguments for node:assert assertions.
๐ผ This rule is enabled in the following configs: โ
recommended, โ๏ธ unopinionated.
Passing the wrong number of arguments to a node:assert assertion silently produces incorrect results. For example, assert.strictEqual(a) always passes because the comparison never runs.
Each node:assert method has a fixed set of required positional arguments, plus one optional trailing message string. This rule reports when:
- Too few required arguments are passed.
- More arguments are passed than the method accepts (required + 1 optional message).
- A trailing
messageargument is statically known to be neither a string nor anError.
Methods with variable arity (fail) and calls that use spread arguments are not checked.
Examples
import assert from 'node:assert';
// โ
assert.strictEqual(actual);
assert.ok();
assert.deepEqual(a, b, 'message', extra);
assert.ok(value, 42); // message must be a string
// โ
assert.strictEqual(actual, expected);
assert.ok(value);
assert.deepEqual(a, b, 'message');