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">53valu= sp>AB0flatM5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">53val1(sp>1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =1)sp><> sp ansty="le--0:#D6DEEB;--1:#403F">53value> sp><);d ivclassNa="meco"> value"><);d>);d>);d>AEconsB0resuAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53valu= sp>AB0flatM5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">53it1(sp>1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =>1)sp>< {d ivclassNa="meec-li">AE< sp ansty="le--0:#C792EA;--1:#8844">AEretur sp>53itA {d>A53<);d ivclassNa="meco"> { return item;}"><);d>);d>);d>AEconsB0resuAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53valu= sp>AB0flatM5<3(sp ansty="le--0:#C792EA;--1:#8844">AEfunctio3(sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53eleme1(sp>1<1)sp ansty="le--0:#C792EA;--1:#8844">AE1)sp>< {d ivclassNa="meec-li">AE< sp ansty="le--0:#C792EA;--1:#8844">AEretur sp>53elemeA {d>A53<);d ivclassNa="meco"><);d>);d>);d> 44AEco61B0re44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B04AE.>3F5<3() ;divclass="Name">3()><;di vdivclass="Nameexpressive-">44AEco61B0re44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0fla4AE.>31<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v111(>1<111) spans="tyle--0:#C792EA;--1:#88">44AE111)>< => spans="tyle--0:#D6DEEB;--1:#40">3F53v => >4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72chil4AE.>3F<53) ;divclass="Name"> value.childr">53)>;di><;di vdivclass="Nameexpressive-">44AEco61B0re44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0fla4AE.>31<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v111(>1<111) spans="tyle--0:#C792EA;--1:#88">44A111)> spans="tyle--0:#D6DEEB;--1:#40">3F53 [val>6E7<2... spans="tyle--0:#D6DEEB;--1:#40">3F53v2...>4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72ex4AE.>3F5<3]) ;divclass="Name"> [value, ...value.extra">3])>;di><;di vdivclass="Nameexpressive-">44AEco61B0re44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0fla4AE.>31<111( spans="tyle--0:#D7DBE0;--1:#40">3F53v111(>1<111) spans="tyle--0:#C792EA;--1:#88">44AE111)>< => spans="tyle--0:#82AAFF;--1:#3B">61B0trans => > transform(valu">;di>
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.