π Require escape sequences to use uppercase or lowercase values.
πΌ This rule is enabled in the following configs: β
recommended, π¨ recommended-css, π§© recommended-json, π recommended-soml, π οΈ recommended-toml, π recommended-yaml, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
Enforces a consistent escaped value style by defining escape sequence values with uppercase or lowercase characters. The default style is uppercase, which promotes readability by making the escaped value more distinguishable from the identifier.
Tagged template literals are ignored because tag functions can observe the raw escape sequences.
In SOML, the configured case is ignored because Unicode escapes must use lowercase hexadecimal digits. Literal strings and keys are skipped.
In TOML, it checks basic strings and quoted keys, including multiline strings. It preserves \u and \U prefixes and also normalizes parser-tolerated \x escapes, which TOML 1.0 does not define. Literal strings and keys are skipped.
In JSON, JSONC, and JSON5, it checks strings and quoted keys, including JSON5 hexadecimal escapes. In YAML, it checks hexadecimal and Unicode escapes in double-quoted scalars. In CSS, it checks one- to six-digit hexadecimal escapes in identifiers, strings, and URLs, preserving escape-terminating whitespace and skipping comments.
// β
const foo = '\xa9';
// β
const foo = '\xA9';// β
const foo = '\ud834';
// β
const foo = '\uD834';// β
const foo = '\u{1d306}';
// β
const foo = '\u{1D306}';// β
const foo = '\ca';
// β
const foo = '\cA';Type: string
Default: 'uppercase'
'uppercase'(default)- Always use escape sequence values with uppercase characters.
'lowercase'- Always use escape sequence values with lowercase characters.
Example:
{
'unicorn/escape-case': ['error', 'lowercase']
}// β
const foo = '\xA9';
// β
const foo = '\xa9';// β
const foo = '\uD834';
// β
const foo = '\ud834';// β
const foo = '\u{1D306}';
// β
const foo = '\u{1d306}';// β
const foo = '\cA';
// β
const foo = '\ca';