require-unicode-regexp
Added in v0.9.1Configuration
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
- When flags come from a newly constructed RegExp object's property, such as
RegExp("g", "u").source, rslint may skip a call that ESLint reports. - With computed
['__proto__']properties in constant objects, rslint follows own-property semantics and can report a constructor call that ESLint skips. - Capture names or Unicode properties newer than the bundled TypeScript parser's Unicode data can receive a diagnostic without a flag suggestion.
- For a negated
vclass where a range is followed by a string-valued operand, rslint omits ESLint's suggestion because JavaScript would reject the result.