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)) {}