ava/no-negated-assertion

February 10, 2026 ยท View on GitHub

๐Ÿ“ Disallow negated assertions.

๐Ÿ’ผ This rule is enabled in the โœ… recommended config.

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

Using negated arguments in assertions like t.true(!x) is harder to read than using the opposite assertion t.false(x). This rule enforces using the positive assertion method instead of negating the argument.

Examples

import test from 'ava';

test('foo', t => {
	t.true(!value); // โŒ
	t.false(value); // โœ…

	t.false(!value); // โŒ
	t.true(value); // โœ…

	t.truthy(!value); // โŒ
	t.falsy(value); // โœ…

	t.falsy(!value); // โŒ
	t.truthy(value); // โœ…

	t.true(!!value); // โŒ (double negation is unnecessary)
	t.true(value); // โœ…
});