Skip to content

Commit

Permalink
Fix .flatmap() description for 'prefer-flat-map'
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanWard97 authored and freaktechnik committed Nov 24, 2021
1 parent 620bb46 commit 1d78af1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ Alternatively you can use a [configuration](#configurations) included with this

### `prefer-flat-map`

Use `.flatMap()` to flatten an array and map the values instead of using
`.flat().map()`.
Use `.flatMap()` to map and then flatten an array instead of using `.map().flat()`.

This rule is auto fixable.

Expand All @@ -293,7 +292,7 @@ This rule is auto fixable.
Code that triggers this rule:

```js
const flattenedAndMapped = array.map((p) => p).flat();
const mappedAndFlattened = array.map((p) => p).flat();

const flatWithDefaultDepth = array.map((r) => r).flat(1);
```
Expand All @@ -307,7 +306,7 @@ const flattened = array.flat();

const mapped = array.map((r) => r + 1);

const mappedThenFlattened = array.flat().map((r) => r + 1);
const flattenedThenMapped = array.flat().map((r) => r + 1);

const flatMappedWithExtra = array.map((r) => r + 1).reverse().flat();

Expand Down

0 comments on commit 1d78af1

Please sign in to comment.