Reports regex patterns that use ambiguous or invalid syntax from Annex B.
✅ This rule is included in the ts logical and logicalStrict presets.
ECMAScript Annex B defines legacy regex syntax that browsers must support for web compatibility but is considered ambiguous or deprecated.
This includes octal escapes in patterns, incomplete escape sequences, useless escapes, and unescaped special characters outside of character classes.
Using strict regex syntax ensures better clarity and cross-platform compatibility.
When the u (unicode) or v (unicode sets) flag is present, JavaScript already enforces strict regex parsing, so this rule skips those patterns.
76// Octal escapes in regex patterAEconsB0rAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F1/sp><\1sp ansty="le--0:#D9F5DD;--1:#1111">1\1sp><1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meec-li">AEconsB0rAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#F78C6C;--1:#AA09">821/sp><\0sp ansty="le--0:#5CA7E4;--1:#3A68">8\0sp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp>3;d><3;d ivclassNa="meec-li">d3;d>76// Incomplete escape sequencAEconsB0rAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#F78C6C;--1:#AA09">821/sp><\xsp ansty="le--0:#5CA7E4;--1:#3A68">8\xsp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meec-li">AEconsB0rAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#F78C6C;--1:#AA09">821/sp><\usp ansty="le--0:#5CA7E4;--1:#3A68">8F1\usp><23sp ansty="le--0:#D9F5DD;--1:#1111">123sp><1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp>3;d><3;d ivclassNa="meec-li">AEconsB0rAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#F78C6C;--1:#AA09">821/sp><\csp ansty="le--0:#5CA7E4;--1:#3A68">8\csp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp>3;d><3;d ivclassNa="meec-li">d3;d>76// Unescaped brackets outside character classAEconsB0rAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F1/sp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meec-li">AEconsB0rAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">8F1/sp>1<1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp>3;d><3;d ivclassNa="meec-li">d3;d>76// Useless escapAEconsB0rAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#F78C6C;--1:#AA09">821/sp><\qsp ansty="le--0:#D9F5DD;--1:#1111">1\qsp><1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meec-li">AEconsB0rAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#F78C6C;--1:#AA09">821/sp><\!sp ansty="le--0:#D9F5DD;--1:#1111">1\!sp><1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp>3;d><3;d ivclassNa="meec-li">d3;d>76// Same issues with RegExp constructAEconsB0re<10sp ansty="le--0:#C792EA;--1:#8844">AE 10sp><= sp ansty="le--0:#7FDBCA;--1:#096E">72n= sp>AB0RegE5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#F78C6C;--1:#AA09">821"sp><\\sp ansty="le--0:#ECC48D;--1:#984E">4\\sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><);d ivclassNa="meco"><);d>);d>);d> 6376// Use hexadecimal escapes instead of o44AEco61B<0re1 spans="tyle--0:#C792EA;--1:#88">440re1>6<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#F78C6C;--1:#AA">0982111/><\x01 spans="tyle--0:#D9F5DD;--1:#11">1\x01><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>44AEco61B<0re2 spans="tyle--0:#C792EA;--1:#88">440re2>6<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#F78C6C;--1:#AA">0982111/><\x07 spans="tyle--0:#D9F5DD;--1:#11">1\x07><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>c6376// Complete escape seque44AEco61B<0re3 spans="tyle--0:#C792EA;--1:#88">440re3>6<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#F78C6C;--1:#AA">0982111/><\x1F spans="tyle--0:#D9F5DD;--1:#11">1\x1F><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>44AEco61B<0re4 spans="tyle--0:#C792EA;--1:#88">440re4>6<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#F78C6C;--1:#AA">0982\u111/><0123 spans="tyle--0:#D9F5DD;--1:#11">10123><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>44AEco61B<0re5 spans="tyle--0:#C792EA;--1:#88">440re5>6<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#82AAFF;--1:#3B">61B111/><0\cA spans="tyle--0:#D9F5DD;--1:#11">10\cA><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>c6376// Escape brackets outside character cla44AEco61B<0re6 spans="tyle--0:#C792EA;--1:#88">440re6>6<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fa spans="tyle--0:#F78C6C;--1:#AA">0988Fa><82\] spans="tyle--0:#D9F5DD;--1:#11">182\]><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>44AEco61B<0re7 spans="tyle--0:#C792EA;--1:#88">440re7>6<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fa spans="tyle--0:#F78C6C;--1:#AA">0988Fa><82\{ spans="tyle--0:#D9F5DD;--1:#11">182\{><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>c6376// No useless escapes ne44AEco61B<0re8 spans="tyle--0:#C792EA;--1:#88">440re8>6<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fq spans="tyle--0:#D9F5DD;--1:#11">188Fq><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>44AEco61B<0re9 spans="tyle--0:#C792EA;--1:#88">440re9>6<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88F! spans="tyle--0:#D9F5DD;--1:#11">188F!><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/>c6376// Unicode mode enforces strict par44AEco61B0446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#5CA7E4;--1:#3A">68111/><8F\1 spans="tyle--0:#D9F5DD;--1:#11">18F\1><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fu spans="tyle--0:#D6DEEB;--1:#40">388Fu>44AEco61B044A6E7<2new spans="tyle--0:#C792EA;--1:#88">42new><4AE spans="tyle--0:#82AAFF;--1:#3B">61B0Re4AE >31<111" spans="tyle--0:#F78C6C;--1:#AA">09111"><82\\ spans="tyle--0:#ECC48D;--1:#98">482\\>1<111" spans="tyle--0:#C792EA;--1:#88">44111">1<111" spans="tyle--0:#ECC48D;--1:#98">4111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name">53)>
This rule is not configurable.
If you are intentionally using legacy regex syntax for compatibility with very old JavaScript environments or specific regex behavior, you may choose to disable this rule.
However, in modern development, using strict regex syntax is recommended.