Skip to content

unicorn/no-hex-escape Pedantic

🛠️ An auto-fix is available for this rule.

What it does

Enforces a convention of using Unicode escapes instead of hexadecimal escapes for consistency and clarity.

Why is this bad?

Examples

Examples of incorrect code for this rule:

javascript
const foo = "\x1B";
const foo = `\x1B${bar}`;

Examples of correct code for this rule:

javascript
const foo = "\u001B";
const foo = `\u001B${bar}`;

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny unicorn/no-hex-escape
json
{
  "rules": {
    "unicorn/no-hex-escape": "error"
  }
}

References

Released under the MIT License.