Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 529 Bytes

prefer-filter.md

File metadata and controls

25 lines (18 loc) · 529 Bytes

Prefer filter

When using R.forEach with a single if statement, you should probably use R.filter or R.some instead.

Rule Details

This rule takes one argument, maximum path length (default is 3).

The following patterns are considered warnings:

R.forEach(users, function (user) {
  if (user.name.givenName === "Bob") {
    // ...
  }
});

The following patterns are not considered warnings:

const x = R.filter(users, function (user) {
  return !user.active && user.name.givenName === "Bob";
});