pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/hexadecimal-escape |
enforce consistent usage of hexadecimal escape |
v0.9.0 |
🔧 This rule is automatically fixable by the --fix
CLI option.
enforce consistent usage of hexadecimal escape
Characters that can use hexadecimal escape can use both hexadecimal escape and unicode escape.
This rule aims to enforce the consistent use of hexadecimal escapes.
/* eslint regexp/hexadecimal-escape: "error" */
/* ✓ GOOD */
var foo = /\x0a/;
/* ✗ BAD */
var foo = /\u000a/;
var foo = /\u{a}/u;
{
"regexp/hexadecimal-escape": [
"error",
"always", // or "never"
]
}
"always"
... Unicode escape characters that can use hexadecimal escape must always use hexadecimal escape. This is default."never"
... Disallows the use of hexadecimal escapes on all characters.
/* eslint regexp/hexadecimal-escape: ["error", "never"] */
/* ✓ GOOD */
var foo = /\u000a/;
var foo = /\u{a}/u;
/* ✗ BAD */
var foo = /\x0a/;
This rule was introduced in eslint-plugin-regexp v0.9.0