Skip to contentSlop Block

no-array-filter-map

Hint

Avoid .filter().map() and .map().filter() on arrays. Without type information, objects with similar methods also match.

const emails = users.filter((user) => user.active).map((user) => user.email);filter and map in sequence build an intermediate array
const found = users.map(lookup).filter((value) => value !== undefined);filter and map in sequence build an intermediate array
// ast-grep-ignore: no-array-filter-map-typescript

How to fix

Use iterator helpers (array.values().filter(...).map(...).toArray()), a single flatMap, or a loop that pushes into one array.

The rule does not check types, so it also reports objects with similar methods.