consistent-assert-throws-callback-style
July 3, 2026 ยท View on GitHub
๐ Enforce a consistent body style for assert.throws() arrow callbacks.
๐ซ This rule is disabled in the following configs: โ
recommended, โ๏ธ unopinionated.
๐ง This rule is automatically fixable by the --fix CLI option.
Enforces block or expression bodies for assert.throws() arrow callbacks.
It is off by default. Set your preferred style.
The default block style fixes expression bodies to block bodies. The original expression is evaluated as a non-returned expression statement.
The expression style reports only single-expression block bodies. Multi-statement blocks and throw cannot be converted.
Autofix is skipped for async callbacks, explicit return types, unsafe comment moves, and split-line arrows.
Options
style('block'|'expression', default'block') โ which callback body style to require.
{
'node-test/consistent-assert-throws-callback-style': ['error', {style: 'block'}]
}
Examples
With the default {style: 'block'}:
import assert from 'node:assert';
// โ
assert.throws(() => parse(input), SyntaxError);
// โ
assert.throws(() => {
parse(input);
}, SyntaxError);
With {style: 'expression'}:
import assert from 'node:assert';
// โ
assert.throws(() => {
parse(input);
}, SyntaxError);
// โ
assert.throws(() => parse(input), SyntaxError);