no-useless-assertion
July 2, 2026 Β· View on GitHub
π Disallow assert.doesNotThrow() and assert.doesNotReject().
πΌπ« This rule is enabled in the β
recommended config. This rule is disabled in the βοΈ unopinionated config.
assert.doesNotThrow() and assert.doesNotReject() catch an error only to rethrow it, so they add nothing over just running the code. The Node.js docs say so directly: "Using assert.doesNotThrow() is actually not useful because there is no benefit in catching an error and then rethrowing it." If the code under test throws, the test fails either way β but calling it directly gives a clearer stack trace.
This rule reports assert.doesNotThrow() and assert.doesNotReject(). Call the code directly, and add a comment if it helps explain why it must not throw.
Examples
import assert from 'node:assert';
// β
assert.doesNotThrow(() => parse(input));
await assert.doesNotReject(() => load(url));
// β
parse(input);
await load(url);