Reports regex character escapes that can be expressed more consistently using hexadecimal escapes.
✅ This rule is included in the ts stylisticStrict presets.
Characters in the range 0x00-0xFF can be expressed using either hexadecimal escapes (\xNN) or Unicode escapes (\uNNNN, \u{N}).
Hexadecimal escapes are more concise for this range and provide a consistent representation.
This rule enforces the use of hexadecimal escapes for characters that can be represented in two hex digits.
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">8 =sp>1<1/sp ansty="le--0:#F78C6C;--1:#AA09">82\u001/sp><0asp ansty="le--0:#D9F5DD;--1:#1111">10asp><1/sp ansty="le--0:#D6DEEB;--1:#403F">51/sp><3;d ivclassNa="meco">;d>/;d>3;d>AEconsB0patteAE< =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">8F{\usp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>5<3;d ivclassNa="meco">3;d>AEconsB0patteAE< =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">8F{00f\usp>1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">81/sp>5<3;d ivclassNa="meco">3;d> 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#F78C6C;--1:#AA">0982111/><\x0a spans="tyle--0:#D9F5DD;--1:#11">1\x0a><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/><0a/>0a/><;di vdivclass="Nameexpressive-">44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#F78C6C;--1:#AA">0982111/><\xff spans="tyle--0:#D9F5DD;--1:#11">1\xff><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fu spans="tyle--0:#D6DEEB;--1:#40">388Fu>;di><;di vdivclass="Nameexpressive-">6376// Unicode escapes are fine for values > <0xF Fdivclass="Nameec-">44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#F78C6C;--1:#AA">0982\u111/><0100 spans="tyle--0:#D9F5DD;--1:#11">10100><111/ spans="tyle--0:#5CA7E4;--1:#3A">6111/><88Fu spans="tyle--0:#D6DEEB;--1:#40">388Fu>0xF> 0xFFconst pattern = /\u010"><0/u>0/u>;di><;di vdivclass="Nameexpressive-">6376// Control characters with standard escapes are 44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">188F ><111/ spans="tyle--0:#82AAFF;--1:#3B">61B0\t111/><\n\r spans="tyle--0:#D9F5DD;--1:#11">1\n\r><111/ spans="tyle--0:#D6DEEB;--1:#40">3111/><\r/>\r/>;di>
This rule is not configurable.
If your codebase has established conventions around using Unicode escapes for consistency with characters outside the 0x00-0xFF range, you might prefer to disable this rule.
Some teams prefer the uniformity of always using Unicode escapes regardless of the character value.