no-negated-array-predicate

June 13, 2026 ยท View on GitHub

๐Ÿ“ Disallow negated array predicate calls.

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

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

Prefer swapping Array#some() and Array#every() with a negated predicate instead of negating the whole call.

This applies De Morgan's laws in the small, focused case where the callback has a directly returned expression.

Examples

// โŒ
const isMissing = !array.some(element => isUnicorn(element));

// โœ…
const isMissing = array.every(element => !isUnicorn(element));
// โŒ
const isNotEveryUnicorn = !array.every(element => isUnicorn(element));

// โœ…
const isNotEveryUnicorn = array.some(element => !isUnicorn(element));
// โŒ
if (!array.some(element => !isUnicorn(element))) {}

// โœ…
if (array.every(element => isUnicorn(element))) {}
// โœ…
if (!array.every(Boolean)) {}