eslint-plugin-remeda
Version:
ESLint plugin for Remeda library.
34 lines (22 loc) ⢠615 B
Markdown
# remeda/prefer-map
š¼ This rule is enabled in the ā
`recommended` config.
<!-- end auto-generated rule header -->
When using `R.forEach` that pushes into an array, it could improve readability to use `R.map` instead.
## Rule Details
This rule takes no arguments.
The following patterns are considered warnings:
```js
R.forEach(arr, function (x) {
newArr.push(f(x));
});
```
The following patterns are not considered warnings:
```js
R.forEach(arr, function (x) {
if (x.a) {
a.push(x);
}
});
```
## When Not To Use It
If you do not want to enforce using `map`, you should not use this rule.