Skip to content

regexUnicodeEscapes

Enforces consistent Unicode escape style in regex patterns by preferring codepoint escapes.

✅ This rule is included in the ts preset.

Enforces consistent Unicode escape style in regex patterns by preferring \u{XXXX} (codepoint escape) over \uXXXX (4-digit Unicode escape) when the u or v flag is present.

The \u{...} format is more flexible, readable, and consistent with the modern Unicode handling in JavaScript.

AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#F78C6C;--1:#AA09">82\u00<41sp ansty="le--0:#D9F5DD;--1:#1111">1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">85<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#F78C6C;--1:#AA">09<82\u spans="tyle--0:#7FDBCA;--1:#09">6E72{0<041} spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6<88Fu spans="tyle--0:#D6DEEB;--1:#40">3<}/u>
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#82AAFF;--1:#3B61">B<0[sp ansty="le--0:#F78C6C;--1:#AA09">82\u0041\u00<42sp ansty="le--0:#82AAFF;--1:#3B61">B<0]sp ansty="le--0:#D9F5DD;--1:#1111">1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">85<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#82AAFF;--1:#3B">6<1B0[ spans="tyle--0:#F78C6C;--1:#AA">09<82\u spans="tyle--0:#82AAFF;--1:#3B">61B0{0<041} spans="tyle--0:#F78C6C;--1:#AA">09<82\u spans="tyle--0:#82AAFF;--1:#3B">61B0{00<42}] spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6<88Fu spans="tyle--0:#D6DEEB;--1:#40">3<]/u>
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#82AAFF;--1:#3B61">B<0[sp ansty="le--0:#F78C6C;--1:#AA09">82\u00<41sp ansty="le--0:#82AAFF;--1:#3B61">B<0-sp ansty="le--0:#F78C6C;--1:#AA09">82\u00<5Asp ansty="le--0:#82AAFF;--1:#3B61">B<0]sp ansty="le--0:#D9F5DD;--1:#1111">1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">85<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#82AAFF;--1:#3B">6<1B0[ spans="tyle--0:#F78C6C;--1:#AA">09<82\u spans="tyle--0:#82AAFF;--1:#3B">61B0{00<41}- spans="tyle--0:#F78C6C;--1:#AA">09<82\u spans="tyle--0:#82AAFF;--1:#3B">61B0{00<5A}] spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6<88Fu spans="tyle--0:#D6DEEB;--1:#40">3<]/u>
AEconsB0patteAE< =sp ansty="le--0:#5CA7E4;--1:#3A68">81<1/sp ansty="le--0:#F78C6C;--1:#AA09">82\u00<41sp ansty="le--0:#D9F5DD;--1:#1111">1<1/sp ansty="le--0:#5CA7E4;--1:#3A68">85<3;d ivclassNa="meco">
44AEco61B0pat446<88F spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#F78C6C;--1:#AA">09<82\u spans="tyle--0:#7FDBCA;--1:#09">6E72{0<041} spans="tyle--0:#D9F5DD;--1:#11">1<111/ spans="tyle--0:#5CA7E4;--1:#3A">6<88Fv spans="tyle--0:#D6DEEB;--1:#40">3<}/v>

This rule is not configurable.

If you need to support environments that do not have the u or v flag, or if you intentionally use 4-digit Unicode escapes as a stylistic preference, you might want to disable this rule. This rule is not enabled by default in Flint because the preference for \u{...} over \uXXXX is more opinionated than what most projects prefer.