# 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`.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

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

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 4} */}
```js
const notice = "\xA9 2026 Example Inc.";
const reset = `\x1B[0m`;
const controlCharacters = /[\x00-\x1F]/;
```

Not reported:

{/* good */}
```js
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:

{/* good */}
```js
const source = String.raw`\x1B\[\d+m`;
const help = "Write \\xA9 for the copyright sign";
```
