no-useless-escape inside `new RegExp`
See original GitHub issueWhat version of ESLint are you using? v2.9.0 What parser (default, Babel-ESLint, etc.) are you using? standard Please show your full configuration:
"ecmaVersion": 6,
"extends": "standard",
"installedESLint": true,
"plugins": [
"standard"
],
"env": {
"node": true,
"browser": true
},
"rules": {
"comma-style": [
"error"
, "first"
]
, "one-var": ["error", {
"var": "always",
"let": "always",
"const": "always"
}]
, "space-before-function-paren": ["error",
{"anonymous": "always", "named": "never"}]
}
What did you do? Please include the actual source code causing the issue.
`new RegExp('[^@]+@[^@]+\.[^@]+')`
What did you expect to happen? Do not get any warnings or error.
What actually happened? Please include the actual, raw output from ESLint.
ESLint: Unnecessary escape character: \.
(no-useless-escape)
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Disable Unnecessary escape character: \/ no-useless-escape
Your regex will work fine if you escape the regular metacharacters inside a character class, but doing so significantly reduces readability.
Read more >regexp/no-useless-escape
This rule reports unnecessary escape characters in RegExp. You may be able to find another mistake by finding unnecessary escapes.
Read more >Escaping, special characters - The Modern JavaScript Tutorial
If we are creating a regular expression with new RegExp , then we don't have to escape / , but need to do...
Read more >Improve Readability with ES6 Template Strings
Yay, no more backslash \ to escape characters in strings! A better way is to use template strings with backticks ( ` )....
Read more >ValidateJavaScript - Online Tool to Find & Fix JavaScript Errors
new -cap new-parens newline-after-var newline-before-return newline-per-chained-call no-alert ... no-inner-declarations no-invalid-regexp no-invalid-this
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
@michaelficarra This regex to check e-mail and I want really escape the
.
because I want to check that.
(dot) is exists inside the string. If I use the alternate syntax of regex like so:then I do not get this warning.
I am using the RegExp to validate email addresses from http://emailregex.com/ which is
this generates two no-useless-escape errors. Any suggestion on how to overcome this without removing this warning in the eslintrc file?
(edited by @not-an-aardvark to add a code block)