Rule: disable regular expression literal
See original GitHub issuePlease describe what the rule should do:
Do not allow Regular Expression Literal.
What category of rule is this? (place an “X” next to just one item)
[X] Warns about a potential error (problem) [ ] Suggests an alternate way of doing something (suggestion) [ ] Enforces code style (layout) [ ] Other (please specify:)
Provide 2-3 code examples that this rule will warn about:
(new RegExp("a\bc")).test("a\bc") // true
/a\bc/.test("a\bc") // false
Why should this rule be included in ESLint (instead of a plugin)? Beacuse this is very important.
Are you willing to submit a pull request to implement this rule?
No.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Disallow use of the `RegExp` constructor in favor of regular ...
This rule disallows the use of the RegExp constructor function with string literals as its arguments. ... and String.raw tagged template literals ......
Read more >prefer-regex-literals - ESLint - Pluggable JavaScript Linter
Rule Details This rule disallows the use of the RegExp constructor function with string literals as its arguments. This rule also disallows the...
Read more >Disable Unnecessary escape character: \/ no-useless-escape
To disable all rules on a specific line, use a line or block ... See https://www.regular-expressions.info/charclass.html for more info, ...
Read more >Regex Tutorial - Turning Modes On and Off for Only Part of ...
In a programming language, you pass them as a flag to the regex constructor or append them to the regex literal. In an...
Read more >Regular Expression (Regex) Tutorial
as . has special meaning in regex. The \ is known as the escape code, which restore the original literal meaning of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@LuoZijun Example of usage
no-restricted-syntax
. I’ve not tested it yet so I’m not sure if it’s OK.RegExp.prototype.compile
is deprecated. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/compile