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