Skip to content

arrayMapIdentities

Reports using .flatMap() with an identity function that returns its argument unchanged.

✅ This rule is included in the ts logical and logicalStrict presets.

Using .flatMap() with a callback that returns its argument unchanged is equivalent to calling .flat(). The .flat() method is more concise and clearly expresses the intent to flatten an array.

AEconsB0resuAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53valuAB0flatM5<3(sp ansty="le--0:#D9F5DD;--1:#1111">1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53val1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =<> sp ansty="le--0:#D6DEEB;--1:#403F">53value sp><);d ivclassNa="meco"><);d>AEconsB0resuAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53valuAB0flatM5<3(sp ansty="le--0:#D9F5DD;--1:#1111">1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53it1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =>< {d ivclassNa="meec-li">AE< sp ansty="le--0:#C792EA;--1:#8844">AEretur53itAA53<);d ivclassNa="meco"><);d>AEconsB0resuAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53valuAB0flatM5<3(sp ansty="le--0:#C792EA;--1:#8844">AEfunctio1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53eleme1<1)sp ansty="le--0:#C792EA;--1:#8844">AE< {d ivclassNa="meec-li">AE< sp ansty="le--0:#C792EA;--1:#8844">AEretur53elemeAA53<);d ivclassNa="meco"><);d>
44AEco61B0re44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B03F5<3() ;divclass="Name"><;di vdivclass="Nameexpressive-">44AEco61B0re44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0fla31<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v1<111) spans="tyle--0:#C792EA;--1:#88">44AE< => spans="tyle--0:#D6DEEB;--1:#40">3F53v >4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72chil3F<53) ;divclass="Name"><;di vdivclass="Nameexpressive-">44AEco61B0re44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0fla31<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v1<111) spans="tyle--0:#C792EA;--1:#88">44A spans="tyle--0:#D6DEEB;--1:#40">3F53 [val>6E7<2... spans="tyle--0:#D6DEEB;--1:#40">3F53v4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72ex3F5<3]) ;divclass="Name"><;di vdivclass="Nameexpressive-">44AEco61B0re44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0fla31<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v1<111) spans="tyle--0:#C792EA;--1:#88">44AE< => spans="tyle--0:#82AAFF;--1:#3B">61B0trans >
3F53(valu

This rule is not configurable.

If you are maintaining a codebase that must support environments where .flat() is not available, you may need to disable this rule. Some older JavaScript environments do not support .flat() or .flatMap() and only polyfill .flatMap(), though this is rare in modern development.