no-compound-assertion
July 3, 2026 ยท View on GitHub
๐ Disallow compound truthiness assertions.
๐ผ This rule is enabled in the following configs: โ
recommended, โ๏ธ unopinionated.
๐ง This rule is automatically fixable by the --fix CLI option.
A compound truthiness assertion like assert.ok(a && b) hides which operand failed. Splitting it into separate assertions gives a focused failure location and keeps the assertion output useful.
This rule reports assert()/assert.ok()/named ok()/test-context t.assert.ok() calls whose asserted value is a top-level && chain.
It autofixes standalone single-argument assertions into one assertion per operand. It does not fix assertions with custom messages, comments, same-line surrounding code/comments, braceless control-flow parents, or t.plan() counts.
Test-context assertions are recognized in tests, subtests, and hooks.
Examples
import assert from 'node:assert';
// โ
assert.ok(user.isActive && user.hasEmail);
assert.ok(a && b && c);
// โ
assert.ok(user.isActive);
assert.ok(user.hasEmail);
assert.ok(a);
assert.ok(b);
assert.ok(c);