Reports parseInt calls with binary, hexadecimal, or octal strings that can be replaced with numeric literals.
✅ This rule is included in the ts stylistic and stylisticStrict presets.
Binary, octal, and hexadecimal numeric literals provide a more readable and direct way to represent numbers in those bases compared to using parseInt() or Number.parseInt() with a radix argument.
Instead of parsing a string representation at runtime, you can use the native literal syntax (0b for binary, 0o for octal, 0x for hexadecimal) which is clearer and more performant.
AEconsB0binaAE <= sp ansty="le--0:#82AAFF;--1:#3B61">B0parseI= sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D11111011"sp><11sp ansty="le--0:#D9F5DD;--1:#1111">111sp><1"sp ansty="le--0:#C792EA;--1:#8844">AE1"sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><22sp ansty="le--0:#D6DEEB;--1:#403F">5322sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0octAE <= sp ansty="le--0:#82AAFF;--1:#3B61">B0parseI= sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D71"sp><67sp ansty="le--0:#D9F5DD;--1:#1111">167sp><1"sp ansty="le--0:#C792EA;--1:#8844">AE1"sp><, sp ansty="le--0:#F78C6C;--1:#AA09">8, sp><28sp ansty="le--0:#D6DEEB;--1:#403F">5328sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0hAE <= sp ansty="le--0:#82AAFF;--1:#3B61">B0parseI= sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D11"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE1"sp><, sp ansty="le--0:#F78C6C;--1:#AA09">82, sp><16sp ansty="le--0:#D6DEEB;--1:#403F">5316sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0valAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53Numb= sp>AB0parseI5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE1"sp><, sp ansty="le--0:#F78C6C;--1:#AA09">82, sp><16sp ansty="le--0:#D6DEEB;--1:#403F">5316sp><);d ivclassNa="meco"><);d>);d>);d> 44AEco61B0bi44A09820b11111<0111 spans="tyle--0:#D6DEEB;--1:#40">30111><111>111><;di vdivclass="Nameexpressive-">44AEco61B0o44A098203<767>767>;di><;di vdivclass="Nameexpressive-">44AEco61B<0hex spans="tyle--0:#C792EA;--1:#88">44A0hex>098203<1f7>1f7>;di><;di vdivclass="Nameexpressive-">44AEco61B0v44A0982<0xff spans="tyle--0:#D6DEEB;--1:#40">30xff>;di>
This rule is not configurable.
If your project heavily deals with literals and you want to be consistent with their parsing, this rule might not be useful for you.