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 message argument is statically known to be neither a string nor an Error.

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');