When comparing the index of an item with an findIndex
method, it can be more expressive to use _.some
, when only the sole existence of a matching item is taken into account.
This rule takes one argument - an options object, with the property includeNative
. If true, the rule will report on all findIndex
, and if false, it will only report on _.indexOf
calls.
The following patterns are considered warnings:
var a = _.findIndex(b, f) === -1
var a = _.findIndex(b, f) >= 0
/*eslint lodash/prefer-some: [2, {"includeNative": true}]*/
if (a.findIndex(f) === -1) {
// ...
}
The following patterns are not considered warnings:
x = _.findIndex(a, f);
_.findIndex(a, f) === 2;
if (_.some(a, f)) {
// ...
}
If you do not want to enforce using _.findIndex
, you should not use this rule.