Skip to content

regexp/unicode-escape

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

enforce consistent usage of unicode escape or unicode codepoint escape

📖 Rule Details

This rule aims to enforce the consistent use of unicode escapes or unicode code point escapes.

This rule does not check for characters that require surrogate pairs (e.g. \ud83d\ude00, \u{1f600}) and patterns that do not have the u flag.

If you want to enforce a character that requires a surrogate pair to unicode code point escape, use the regexp/prefer-unicode-codepoint-escapes rule.

Now loading...

🔧 Options

json5
{
  "regexp/unicode-escape": [
    "error",
    "unicodeCodePointEscape" // or "unicodeEscape"
  ]
}
  • "unicodeCodePointEscape" ... Unicode escape characters must always use unicode code point escapes. This is default.
  • "unicodeEscape" ... Unicode code point escape characters must always use unicode escapes.

"unicodeEscape"

Now loading...

🚀 Version

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

🔍 Implementation