Reports using .apply() or .call() or when the context (this value) provides no benefit.
✅ This rule is included in the ts logical and logicalStrict presets.
Using .apply() .call() or with null or undefined as the context (first argument) provides no benefit over calling the function directly.
Doing so adds unnecessary complexity and reduces code readability.
AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0a3 sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">51(sp><3asp ansty="le--0:#7FDBCA;--1:#096E">73asp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb3 sp><53sp ansty="le--0:#D6DE">EB53sp><, sp ansty="le--0:#D7DB">E, sp><0bsp ansty="le--0:#7FDBCA;--1:#096E">70bsp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb3 sp>1<1)sp ansty="le--0:#D6DEEB;--1:#403F">531)sp>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>53 A53 {d>5<3}d ivclassNa="meec-li">AEconsB0resuAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53a= sp>AB0ca5<3(sp ansty="le--0:#82AAFF;--1:#3B61">B0undefin3(sp>AE<, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><21sp ansty="le--0:#C792EA;--1:#8844">AE21sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><22sp ansty="le--0:#D6DEEB;--1:#403F">5322sp>3}d><);d ivclassNa="meco"><);d>);d>);d>AEfuncti5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0multip3 sp>1<1(sp ansty="le--0:#D7DBE0;--1:#403F">51(sp><3xsp ansty="le--0:#7FDBCA;--1:#096E">73xsp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb3 sp><53sp ansty="le--0:#D6DE">EB53sp><, sp ansty="le--0:#D7DB">E, sp><0ysp ansty="le--0:#7FDBCA;--1:#096E">70ysp><2:sp ansty="le--0:#D6DEEB;--1:#403F">52:sp><3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb3 sp>1<1)sp ansty="le--0:#D6DEEB;--1:#403F">531)sp>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEretu sp>53 A53 {d>5<3}d ivclassNa="meec-li">AEconsB0valAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53multip= sp>AB0ca5<3(sp ansty="le--0:#FF6A83;--1:#A248">48nu3(sp>AE<, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><25sp ansty="le--0:#C792EA;--1:#8844">AE25sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><23sp ansty="le--0:#D6DEEB;--1:#403F">5323sp>3}d><);d ivclassNa="meco"><);d>);d>);d>AEconsB0callbaAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">53messa1(sp>7<2:sp ansty="le--0:#C792EA;--1:#8844">A2:sp>B0stri1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =1)sp><> sp ansty="le--0:#D6DEEB;--1:#403F">53messa> sp>AB0toUpperCa53(<);d ivclassNa="meec-li">53callbaAB0app5<3(sp ansty="le--0:#82AAFF;--1:#3B61">B0undefin3(sp>53,< [sp ansty="le--0:#D9F5DD;--1:#1111">1 [sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dhel1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">53]1"sp>);d><);d ivclassNa="meco"> message.toUpperCase();callback.apply(undefined, ["hello"]"><);d>);d>);d>AEconsB0compuAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1(sp ansty="le--0:#D7DBE0;--1:#403F">51(sp><3asp ansty="le--0:#7FDBCA;--1:#096E">73asp><2:sp ansty="le--0:#C792EA;--1:#8844">A2:sp>B0numbAE<, sp ansty="le--0:#D7DBE0;--1:#403F">5, sp><3bsp ansty="le--0:#7FDBCA;--1:#096E">73bsp><2:sp ansty="le--0:#C792EA;--1:#8844">A2:sp>B0numb1<1)sp ansty="le--0:#C792EA;--1:#8844">AE =1)sp><> sp ansty="le--0:#D6DEEB;--1:#403F">5> sp><3asp ansty="le--0:#C792EA;--1:#8844">AE 3asp><+ sp ansty="le--0:#D6DEEB;--1:#403F">53+ sp>53compuAB0app5<3(sp ansty="le--0:#FF6A83;--1:#A248">48nu3(sp>53,< [sp ansty="le--0:#F78C6C;--1:#AA09">82 [sp><10sp ansty="le--0:#D6DEEB;--1:#403F">5310sp><, sp ansty="le--0:#F78C6C;--1:#AA09">82, sp><20sp ansty="le--0:#D6DEEB;--1:#403F">53]20sp><);d ivclassNa="meco"> a + b;compute.apply(null, [10, 20]"><);d>);d>);d> 44AEfunc361B<0add spans="tyle--0:#D9F5DD;--1:#11">10add><111( spans="tyle--0:#D7DBE0;--1:#40">3111(>6361B0nu<3F53 spans="tyle--0:#D6">DE3F53>D6361B0nu1<111) spans="tyle--0:#D6DEEB;--1:#40">3F111)><53 {divclass="Nameec-">de44AEre3F5<3 a spans="tyle--0:#C792EA;--1:#88">43 a ><4AE+ spans="tyle--0:#D6DEEB;--1:#40">3F54AE+>53 ><3 b ;divclass="Nameec-">33 b>44AEco61B0re44A61B<0add spans="tyle--0:#D6DEEB;--1:#40">30add>0<9821 spans="tyle--0:#C792EA;--1:#88">449821>0<9822 spans="tyle--0:#D6DEEB;--1:#40">3F9822><53) ;divclass="Name">< 2)> 2)>53)><;di vdivclass="Nameexpressive-">44AEco61B0call44A1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53mes111(>64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0st4AE >1<111) spans="tyle--0:#C792EA;--1:#88">44AE111)>< => spans="tyle--0:#D6DEEB;--1:#40">3F53mes => >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0toUpper4AE.>3F5<3() ;divclass="Nameec-">61B0call31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dh111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111">3()><53) ;divclass="Name"> message.toUpperCase();callback("hell">53)>;di><;di vdivclass="Nameexpressive-">6376// Using .call() with a meaningful con44AEco61B<0obj spans="tyle--0:#C792EA;--1:#88">44AE = { val0obj>09<8210 spans="tyle--0:#C792EA;--1:#88">448210>344AEfunc361B0getV11<11() spans="tyle--0:#D6DEEB;--1:#40">3F11()><53 {divclass="Nameec-">de44AEre36E724<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72v4AE.>353 >344AEco61B0contextRe44A3F53getV4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B04AE.>3F53(o;di><;di vdivclass="Nameexpressive-">6376// Using .apply() to pass an array of arguments with con44AEfunc361B0g1<111( spans="tyle--0:#7FDBCA;--1:#09">6E72t111(>3F53 { 6361B0st<3F53 spans="tyle--0:#D6">DEEB3F53>< }, spans="tyle--0:#D7">DBE0gree }, >6361B0st1<111) spans="tyle--0:#D6DEEB;--1:#40">3F111)><53 {divclass="Nameec-">de44AEre3338<34${ spans="tyle--0:#D6DEEB;--1:#40">3F53gree34${>3<834} spans="tyle--0:#ECC48D;--1:#3B">61834}>38<34${ spans="tyle--0:#7FDBCA;--1:#09">6E7234${>4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E724AE.>3<834} spans="tyle--0:#ECC48D;--1:#3B">6834}><1B0! spans="tyle--0:#D6DEEB;--1:#40">31B0!>353 >344AEco61B0pe44AE = { na1<111" spans="tyle--0:#ECC48D;--1:#98">4E4DA111">1<111" spans="tyle--0:#C792EA;--1:#88">44111">33F53g4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0a4AE.>3F53(perso1<111" spans="tyle--0:#ECC48D;--1:#98">4E4DH111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F5111"><3]) ;divclass="Name"><"])>"])>3])>;di>
This rule is not configurable.
If you have a specific coding pattern that requires explicit use of .apply() .call() or for consistency across a large codebase, even when the context is null or undefined, you might choose to disable this rule.
However, in most cases, direct function calls improve code clarity and maintainability.