require-unicode-regexp
UnreleasedConfiguration
rslint.config.ts
Rule Details
Enforces the use of the u or v flag on regular expressions.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
This rule has one object option:
requireFlag:"u"or"v"— requires that particular flag instead of accepting either.
Examples of incorrect code for this rule with { "requireFlag": "u" }:
Examples of correct code for this rule with { "requireFlag": "u" }:
Examples of incorrect code for this rule with { "requireFlag": "v" }:
Examples of correct code for this rule with { "requireFlag": "v" }:
Differences from ESLint
- A pattern is judged against
u-flag syntax when deciding whether the suggestion is safe, so one written inv-flag set notation — the difference operator ([\d--[3]]), a\q{...}string literal — is reported without a suggestion that ESLint would offer. - Unicode property escapes are recognized by their short aliases, so
/\p{L}/is offered the flag while/\p{Letter}/and/\p{Script=Greek}/are reported without a suggestion. - A suggested flag insertion into a template literal that interpolates an expression is refused whenever that template's cooked value already contains the opposite flag character, even when the interpolated expression's source text has no escape sequence of its own — ESLint only inspects the template's literal quasis for that escape check, this rule inspects the whole template source.