escape-case

March 27, 2026 ยท View on GitHub

๐Ÿ“ Require escape sequences to use uppercase or lowercase values.

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ 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.

Examples

// โŒ
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';

Options

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';