consistent-assert-style
July 3, 2026 Β· View on GitHub
π Enforce a consistent truthiness assertion style.
πΌπ« This rule is enabled in the β
recommended config. This rule is disabled in the βοΈ unopinionated config.
π§ This rule is automatically fixable by the --fix CLI option.
assert(value) and assert.ok(value) are aliases. This rule enforces one form.
The default is assert.ok(value): explicit and consistent with the rest of the assert API (strictEqual, match, throws, ok). If you prefer the shorter alias, set style: 'assert'.
This rule only targets callable imports from node:assert, node:assert/strict, assert, and assert/strict. It ignores t.assert.ok(value), because t.assert is not callable.
If you set style: 'assert', do not also enable eslint-plugin-unicorn's consistent-assert, which enforces assert.ok(value).
Options
style
Type: 'assert' | 'assert-ok'
Default: 'assert-ok'
Which truthiness assertion style to require.
{
'node-test/consistent-assert-style': [
'error',
{
style: 'assert-ok'
}
]
}
Examples
With the default (style: 'assert-ok'):
import assert from 'node:assert/strict';
// β
assert(value);
// β
assert.ok(value);
With style: 'assert':
import assert from 'node:assert/strict';
// β
assert.ok(value);
// β
assert(value);