Skip to content

Latest commit

 

History

History
79 lines (53 loc) · 1.72 KB

hexadecimal-escape.md

File metadata and controls

79 lines (53 loc) · 1.72 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/hexadecimal-escape
enforce consistent usage of hexadecimal escape
v0.9.0

regexp/hexadecimal-escape

🔧 This rule is automatically fixable by the --fix CLI option.

enforce consistent usage of hexadecimal escape

📖 Rule Details

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;

🔧 Options

{
  "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.

"never"

/* eslint regexp/hexadecimal-escape: ["error", "never"] */

/* ✓ GOOD */
var foo = /\u000a/;
var foo = /\u{a}/u;

/* ✗ BAD */
var foo = /\x0a/;

👫 Related rules

🚀 Version

This rule was introduced in eslint-plugin-regexp v0.9.0

🔍 Implementation