Skip to content
NewBun 1.4.5 is out. Release notes
AphrodyBun

Linter · Rules

unicorn/no-hex-escape

Require Unicode escapes such as \u001B instead of hexadecimal escapes such as \x1B

"\x1B" and "\u001B" are the same character written two ways. \x only reaches the first 256 characters, so a project that uses it ends up with both forms, and a search for one misses the other. \u works for every character.

The rule checks strings, template literals, and regular expressions.

--fix rewrites \x1B to \u001B.

Configure

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"unicorn/no-hex-escape" = "error" # or "warn"

Examples

Reported:

const notice = "\xA9 2026 Example Inc.";
const reset = `\x1B[0m`;
const controlCharacters = /[\x00-\x1F]/;

Not reported:

const notice = "© 2026 Example Inc.";
const reset = `\u001B[0m`;
const controlCharacters = /[\u0000-\u001F]/;

In String.raw and after an escaped backslash, \x is plain text, not an escape:

const source = String.raw`\x1B\[\d+m`;
const help = "Write \\xA9 for the copyright sign";