prefer-array-some
Added in v0.7.3Configuration
rslint.config.ts
Rule Details
Prefer using Array#some(…) over:
Array#find(…)/Array#findLast(…)when the result is only used as a boolean.Array#findIndex(…)/Array#findLastIndex(…)compared against-1/0.- A non-zero length check on
Array#filter(…).
.some(…) communicates the intent — "is there a match?" — more directly and can stop iterating at the first match.
Typed arrays carry the same methods and are checked too. Keyed collections
(Map, Set, WeakMap, WeakSet) are not: their .find(…) / .filter(…)
are unrelated APIs where the rewrite would not hold.
Examples of incorrect code for this rule:
Examples of correct code for this rule: