pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/no-useless-escape |
disallow unnecessary escape characters in RegExp |
v0.4.0 |
💼 This rule is enabled in the ✅ plugin:regexp/recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
disallow unnecessary escape characters in RegExp
This rule reports unnecessary escape characters in RegExp.
You may be able to find another mistake by finding unnecessary escapes.
/* eslint regexp/no-useless-escape: "error" */
/* ✓ GOOD */
var foo = /\[/
var foo = /\\/
/* ✗ BAD */
var foo = /\a/
var foo = /\x7/
var foo = /\u41/
var foo = /\u{[41]}/
This rule checks for unnecessary escapes with deeper regular expression parsing than the ESLint core's no-useless-escape rule.
/* eslint no-useless-escape: "error" */
// no-useless-escape rule also reports it.
var foo = /\a/
// no-useless-escape rule DOES NOT report it.
var foo = /\x7/
var foo = /\u41/
var foo = /\u{[41]}/
Nothing.
This rule was introduced in eslint-plugin-regexp v0.4.0