When using _.filter and accessing the first or last result, you should probably use _.find
or _.findLast
, respectively.
This rule takes no arguments.
The following patterns are considered warnings:
const x = _.filter(a, f)[0];
const x = _.head(_.filter(a, f));
const x = _(a)
.filter(f)
.head()
const x = _.last(_.filter(a, f));
const x = _.head(_.reject(a, f));
The following patterns are not considered warnings:
const x = _.filter(a, f);
const x = _.filter(a, f)[3];
const x = _.find(a, f);