# escape-case

Rule `unicorn/escape-case`. Require escape sequences to use uppercase or lowercase values.

- Source: unicorn
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 12.8M weekly downloads of presets that enable it
- Trend: +40.7% last quarter
- Rank: #731 by reach, #940 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/escape-case` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/escape-case.md) |
| Oxlint | `unicorn/escape-case` | no | safe | plugin `unicorn`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/escape-case.html) |

## Code examples

### Incorrect: the rule reports this

```js
const foo = '\xa9';
```

```js
const foo = '\ud834';
```

```js
const foo = '\u{1d306}';
```

### Correct: the rule accepts this

```js
const foo = '\xA9';
```

```js
const foo = '\uD834';
```

```js
const foo = '\u{1D306}';
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/escape-case": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/escape-case": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [Anthony Fu's config](https://lintradar.dev/presets/antfu.md) | ESLint | `@antfu/eslint-config` | 294 | 758.7K | +49.9% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/prefer-includes](https://lintradar.dev/rules/unicorn/prefer-includes.md): Prefer `.includes()` over `.indexOf()`, `.lastIndexOf()`, and `Array#some()` when checking for existence or non-existence.
- [unicorn/no-instanceof-builtins](https://lintradar.dev/rules/unicorn/no-instanceof-builtins.md): Disallow `instanceof` with built-in objects
- [unicorn/throw-new-error](https://lintradar.dev/rules/unicorn/throw-new-error.md): Require `new` when creating an error.
- [unicorn/no-new-buffer](https://lintradar.dev/rules/unicorn/no-new-buffer.md): Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`.
- [unicorn/prefer-number-properties](https://lintradar.dev/rules/unicorn/prefer-number-properties.md): Prefer `Number` static methods over global functions and optionally static properties over global constants.
- [unicorn/prefer-type-error](https://lintradar.dev/rules/unicorn/prefer-type-error.md): Enforce throwing `TypeError` in type checking conditions.

---

Web page: https://lintradar.dev/rules/unicorn/escape-case. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
