Skip to content

Commit 1d78af1

Browse files
EvanWard97freaktechnik
authored andcommitted
Fix .flatmap() description for 'prefer-flat-map'
1 parent 620bb46 commit 1d78af1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ Alternatively you can use a [configuration](#configurations) included with this
283283

284284
### `prefer-flat-map`
285285

286-
Use `.flatMap()` to flatten an array and map the values instead of using
287-
`.flat().map()`.
286+
Use `.flatMap()` to map and then flatten an array instead of using `.map().flat()`.
288287

289288
This rule is auto fixable.
290289

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

295294
```js
296-
const flattenedAndMapped = array.map((p) => p).flat();
295+
const mappedAndFlattened = array.map((p) => p).flat();
297296

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

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

310-
const mappedThenFlattened = array.flat().map((r) => r + 1);
309+
const flattenedThenMapped = array.flat().map((r) => r + 1);
311310

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

0 commit comments

Comments
 (0)