Reports using string arguments in setTimeout, setInterval, setImmediate, execScript, or the Function constructor.
✅ This rule is included in the ts logical and logicalStrict presets.
JavaScript’s eval() function is generally discouraged because it executes arbitrary strings as code, making programs harder to analyze and creating potential security vulnerabilities.
Several other APIs similarly evaluate strings as code:
setTimeout() and setInterval() accept a string as their first argument
setImmediate() accepts a string as its first argument
execScript() (Internet Explorer only) accepts a string
- The
Function constructor creates functions from strings
These “implied evals” have the same problems as eval(): they’re difficult to analyze statically, prevent many optimizations, and can introduce security risks if the string contains untrusted content.
B0setTimeo5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dalert('Hello'1"sp><);sp ansty="le--0:#D9F5DD;--1:#1111">1);sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8210, sp><00sp ansty="le--0:#D6DEEB;--1:#403F">5300sp><);d ivclassNa="meco"><);d>);d>);d>B0setInterv5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dcounter+1"sp><+;sp ansty="le--0:#D9F5DD;--1:#1111">1+;sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><, sp ansty="le--0:#F78C6C;--1:#AA09">821, sp><00sp ansty="le--0:#D6DEEB;--1:#403F">5300sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0coAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1= sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dconsole.log('executed'1"sp><);sp ansty="le--0:#D9F5DD;--1:#1111">1);sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">51"sp><3;d ivclassNa="meec-li">B0setTimeo53(code<, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><20sp ansty="le--0:#D6DEEB;--1:#403F">5320sp>3;d><);d ivclassNa="meco"><);d>);d>);d>72n5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0Functi3 sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">41"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><, sp ansty="le--0:#D9F5DD;--1:#1111">1, sp><1"sp ansty="le--0:#ECC48D;--1:#984E">41"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><, sp ansty="le--0:#D9F5DD;--1:#1111">1, sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dreturn a +1"sp>< bsp ansty="le--0:#D9F5DD;--1:#1111">1 bsp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><);d ivclassNa="meco"><);d>);d>);d>53windAB0setTimeo5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4DdoSomething1"sp><()sp ansty="le--0:#D9F5DD;--1:#1111">1()sp><1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><, sp ansty="le--0:#F78C6C;--1:#AA09">821, sp><00sp ansty="le--0:#D6DEEB;--1:#403F">5300sp><);d ivclassNa="meco"><);d>);d>);d> 61B0setTim311<11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">de61B0a31<111" spans="tyle--0:#ECC48D;--1:#98">4E4DH111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111">53 ><53) ;divclass="Nameec-">3F5<3}, spans="tyle--0:#F78C6C;--1:#AA">09823}, ><1000 spans="tyle--0:#D6DEEB;--1:#40">3F1000>53)><53) ;divclass="Name"> { alert("Hello");}, 10"><00)>00)>53)><;di vdivclass="Nameexpressive-">61B0setInte311<11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53cou53 >44353 >3F5<3}, spans="tyle--0:#F78C6C;--1:#AA">0983}, ><2100 spans="tyle--0:#D6DEEB;--1:#40">3F2100><53) ;divclass="Name"> { counter++;}, 1"><00)>00)>53)>;di><;di vdivclass="Nameexpressive-">61B0setTim3F53(myCallba0<9820 spans="tyle--0:#D6DEEB;--1:#40">3F9820><53) ;divclass="Name">< 0)> 0)>53)>;di><;di vdivclass="Nameexpressive-">44AEco61B<0add spans="tyle--0:#C792EA;--1:#88">44A0add>1<111( spans="tyle--0:#D7DBE0;--1:#40">3111(>64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu4AE >44364<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu4AE >1<111) spans="tyle--0:#C792EA;--1:#88">44AE111)>< => spans="tyle--0:#D6DEEB;--1:#40">3 => >44A3F<53b ;divclass="Name"> a "><+ b>+ b>53b>;di><;di vdivclass="Nameexpressive-">61B0setTim3F53(han4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B04AE.>3F53(contex098<2100 spans="tyle--0:#D6DEEB;--1:#40">3F2100><53) ;divclass="Name"><00)>00)>53)>;di>
This rule is not configurable.
If you have a specific use case that requires dynamic code evaluation and you’ve carefully considered the security implications, you might disable this rule for those specific instances.
For example, certain build tools or code playgrounds may legitimately need to use these APIs with string arguments.
Consider using Flint disable comments for those specific lines rather than disabling the rule entirely.