prefer-regex-literals
Configuration
rslint.config.ts
Rule Details
This rule disallows RegExp constructor calls when the same regular expression
can be written as a literal.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
This rule accepts an options object with the following property:
disallowRedundantWrapping(boolean, defaultfalse) — whentrue, additionally reports regex literals that are unnecessarily wrapped in aRegExpconstructor.
To enable this option:
Examples of incorrect code for this rule with
{ "disallowRedundantWrapping": true }:
Examples of correct code for this rule with
{ "disallowRedundantWrapping": true }:
Differences from ESLint
- rslint does not vary suggestions by configured ECMAScript version; a diagnostic is still reported when the pattern arguments are static.