Reports using .filter()[0] instead of .find() when looking for a single element.
✅ This rule is included in the ts stylistic and stylisticStrict presets.
When searching for the first item in an array matching a condition, using .filter(...)[0] is less efficient than using .find(...).
The .find() method stops searching after finding the first match, whereas .filter() iterates through the entire array.
AEconsB0valuAE< =sp ansty="le--0:#D6DEEB;--1:#403F">53 =sp>< [sp ansty="le--0:#F78C6C;--1:#AA09">8 [sp><21sp ansty="le--0:#D6DEEB;--1:#403F">5321sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><22sp ansty="le--0:#D6DEEB;--1:#403F">5322sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><23sp ansty="le--0:#D6DEEB;--1:#403F">5323sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><24sp ansty="le--0:#D6DEEB;--1:#403F">5324sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><25sp ansty="le--0:#D6DEEB;--1:#403F">5325sp><];d ivclassNa="meec-li">AEconsB0firAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53valu= sp>AB0filt5<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">53val> sp>AE <> sp ansty="le--0:#F78C6C;--1:#AA09">8> sp><23sp ansty="le--0:#D6DEEB;--1:#403F">5323sp><)[sp ansty="le--0:#F78C6C;--1:#AA09">8)[sp><20sp ansty="le--0:#D6DEEB;--1:#403F">5320sp>];d><];d ivclassNa="meco"> value > 3)[0"><];d>];d>];d>AEconsB0useAE< =sp ansty="le--0:#D6DEEB;--1:#403F">53 [{ name =sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4DAli1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">53 }, { name1"sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4DB1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">53 }1"sp><];d ivclassNa="meec-li">AEconsB0usAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53use= sp>AB0filt5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">53us1(sp>1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =1)sp><> sp ansty="le--0:#D6DEEB;--1:#403F">53us> sp>A72naAE ==<= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4DAli1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><)[sp ansty="le--0:#F78C6C;--1:#AA09">8)[sp><20sp ansty="le--0:#D6DEEB;--1:#403F">5320sp>];d><];d ivclassNa="meco"> user.name === "Alice")[0"><];d>];d>];d> 44AEco61B0va443F<53 [ spans="tyle--0:#F78C6C;--1:#AA">053 [><9821 spans="tyle--0:#D6DEEB;--1:#40">3F9821><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9822 spans="tyle--0:#D6DEEB;--1:#40">3F9822><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9823 spans="tyle--0:#D6DEEB;--1:#40">3F9823><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9824 spans="tyle--0:#D6DEEB;--1:#40">3F9824><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9825 spans="tyle--0:#D6DEEB;--1:#40">3F9825><53] ;divclass="Nameec-">44AEco61B0f44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B04AE.>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 => >44A spans="tyle--0:#F78C6C;--1:#AA">0 ><9823 spans="tyle--0:#D6DEEB;--1:#40">3F9823>53]><53) ;divclass="Name"> value >">< 3)> 3)>53)><;di vdivclass="Nameexpressive-">44AEco61B0u443F53 [{ na1<111" spans="tyle--0:#ECC48D;--1:#98">4E4DA111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F53 }, { na111">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F53111">< }] ;divclass="Nameec-">44AEco61B044A3F53u4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B04AE.>31<111( spans="tyle--0:#D7DBE0;--1:#40">3F53111(>1<111) spans="tyle--0:#C792EA;--1:#88">44AE111)>< => spans="tyle--0:#D6DEEB;--1:#40">3F53 => >4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E724AE.>44AE <=== spans="tyle--0:#D9F5DD;--1:#11">1=== ><111" spans="tyle--0:#ECC48D;--1:#98">4E4DA111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"> }]><53) ;divclass="Name"> user.name === "Alic">53)>;di><;di vdivclass="Nameexpressive-">44AEco61B0va443F<53 [ spans="tyle--0:#F78C6C;--1:#AA">053 [><9821 spans="tyle--0:#D6DEEB;--1:#40">3F9821><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9822 spans="tyle--0:#D6DEEB;--1:#40">3F9822><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9823 spans="tyle--0:#D6DEEB;--1:#40">3F9823><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9824 spans="tyle--0:#D6DEEB;--1:#40">3F9824><53, spans="tyle--0:#F78C6C;--1:#AA">053, ><9825 spans="tyle--0:#D6DEEB;--1:#40">3F9825><53] ;divclass="Nameec-">44AEco61B0allPosi44A3F53va4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0fi4AE.>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 => >44A spans="tyle--0:#F78C6C;--1:#AA">0 ><9820 spans="tyle--0:#D6DEEB;--1:#40">3F9820>53]><53) ;divclass="Name"> value >">< 0)> 0)>53)>;di>
This rule is not configurable.
If you intentionally use .filter(...)[0] to execute side effects in the callback on all array elements before returning the first match, you may want to disable this rule.
However, this pattern is unusual and may indicate a need for code refactoring.