Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 935 Bytes

File metadata and controls

34 lines (22 loc) · 935 Bytes

ava/no-negated-assertion

📝 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); // ✅
});