Skip to content

Latest commit

 

History

History
29 lines (18 loc) · 589 Bytes

prefer-some.md

File metadata and controls

29 lines (18 loc) · 589 Bytes

Prefer R.some

When comparing the index of an item with an findIndex method, it can be more expressive to use R.some, when only the sole existence of a matching item is taken into account.

Rule Details

The following patterns are considered warnings:

var a = R.findIndex(b, f) === -1;

var a = R.findIndex(b, f) >= 0;

The following patterns are not considered warnings:

x = R.findIndex(a, f);

R.findIndex(a, f) === 2;

if (R.some(a, f)) {
  // ...
}

When Not To Use It

If you do not want to enforce using R.findIndex, you should not use this rule.