Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 576 Bytes

prefer-find.md

File metadata and controls

39 lines (27 loc) · 576 Bytes

Prefer find

When using R.filter and accessing the first or last result, you should probably use R.find or R.findLast, respectively.

Rule Details

This rule takes no arguments.

The following patterns are considered warnings:

const x = R.filter(a, f)[0];
const x = R.head(R.filter(a, f));
const x = R.last(R.filter(a, f));
const x = R.head(R.reject(a, f));

The following patterns are not considered warnings:

const x = R.filter(a, f);
const x = R.filter(a, f)[3];
const x = R.find(a, f);