File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -283,8 +283,7 @@ Alternatively you can use a [configuration](#configurations) included with this
283
283
284
284
### ` prefer-flat-map `
285
285
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() ` .
288
287
289
288
This rule is auto fixable.
290
289
@@ -293,7 +292,7 @@ This rule is auto fixable.
293
292
Code that triggers this rule:
294
293
295
294
``` js
296
- const flattenedAndMapped = array .map ((p ) => p).flat ();
295
+ const mappedAndFlattened = array .map ((p ) => p).flat ();
297
296
298
297
const flatWithDefaultDepth = array .map ((r ) => r).flat (1 );
299
298
```
@@ -307,7 +306,7 @@ const flattened = array.flat();
307
306
308
307
const mapped = array .map ((r ) => r + 1 );
309
308
310
- const mappedThenFlattened = array .flat ().map ((r ) => r + 1 );
309
+ const flattenedThenMapped = array .flat ().map ((r ) => r + 1 );
311
310
312
311
const flatMappedWithExtra = array .map ((r ) => r + 1 ).reverse ().flat ();
313
312
You can’t perform that action at this time.
0 commit comments