# consistent-template-literal-escape

Rule `unicorn/consistent-template-literal-escape`. Enforce consistent style for escaping `${` in template literals.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 12M weekly downloads of presets that enable it
- Trend: +40.1% last quarter
- Rank: #822 by reach, #1018 by growth

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
const template = `$\{variableName}`;
```

```js
const template = `\$\{variableName}`;
```

### Correct: the rule accepts this

```js
const template = `\${variableName}`;
```

```js
const message = `Use \${variable} in your code`;
```

```js
const regex = `/\${pattern}/g`;
```

Examples from the ESLint documentation.

## Enable it

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

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

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/consistent-template-literal-escape": "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% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/consistent-assert](https://lintradar.dev/rules/unicorn/consistent-assert.md): Enforce consistent assertion style with `node:assert`.
- [unicorn/empty-brace-spaces](https://lintradar.dev/rules/unicorn/empty-brace-spaces.md): Enforce no spaces between braces.
- [unicorn/no-immediate-mutation](https://lintradar.dev/rules/unicorn/no-immediate-mutation.md): Disallow immediate mutation after assignment and initialization immediately after declaration.
- [unicorn/no-await-expression-member](https://lintradar.dev/rules/unicorn/no-await-expression-member.md): Disallow member access from await expression.
- [unicorn/no-array-reduce](https://lintradar.dev/rules/unicorn/no-array-reduce.md): Disallow `Array#reduce()` and `Array#reduceRight()`.
- [unicorn/no-confusing-array-with](https://lintradar.dev/rules/unicorn/no-confusing-array-with.md): Disallow confusing uses of `Array#with()`.

---

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