Skip to content

octalEscapes

Reports using octal escape sequences in string literals.

✅ This rule is included in the ts javascript presets.

Octal escape sequences (e.g., \01, \02, \377) are a deprecated feature in JavaScript that can lead to confusion and portability issues. They are forbidden in strict mode code, template literals, and are less readable than their modern alternatives. The null character escape sequence \0 (when not followed by an octal digit) is still allowed as it is commonly used and well-understood.

AEconsB0messaAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4DHel82\<07sp ansty="le--0:#ECC48D;--1:#984E">4DWor1<1"sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meec-li">AEconsB0paAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4D82\01\02\<03sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meec-li">AEconsB0octAE <= sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#F78C6C;--1:#AA09">82\3<77sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meco"><";d>
44AEco61B0mes44A1<111" spans="tyle--0:#ECC48D;--1:#98">4E4DH0982<\x07 spans="tyle--0:#ECC48D;--1:#98">4E4DW1<111" spans="tyle--0:#D6DEEB;--1:#40">344AEco61B044A1<111" spans="tyle--0:#ECC48D;--1:#98">4E<4DC: spans="tyle--0:#F78C6C;--1:#AA">0982\x01\x02<\x03 spans="tyle--0:#D9F5DD;--1:#11">1<111" spans="tyle--0:#D6DEEB;--1:#40">344AEco61B0o44A1<111" spans="tyle--0:#F78C6C;--1:#AA">0982<\xFF spans="tyle--0:#D9F5DD;--1:#11">1<111" spans="tyle--0:#D6DEEB;--1:#40">3c6376// The null character escape is all44AEco61B0null44A1<111" spans="tyle--0:#F78C6C;--1:#AA">09<82\0 spans="tyle--0:#D9F5DD;--1:#11">1<111" spans="tyle--0:#D6DEEB;--1:#40">3<\0">

This rule is not configurable.

If you need to maintain compatibility with very old JavaScript engines that don’t support hexadecimal or Unicode escape sequences, you might choose to disable this rule. However, this is extremely rare in modern development.