# unicorn/consistent-template-literal-escape

> Enforce one way to escape `${` in template literals

To write a literal `${` in a template literal you need to escape it, and three spellings work: a backslash before the `$`, before the `{`, or before both. All three give the same string. This rule keeps the first one, `\${`, so an escaped placeholder looks the same everywhere.

Tagged templates aren't checked, because a tag can read the raw text.

`--fix` rewrites the escape.

{/* 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/consistent-template-literal-escape" = "error" # or "warn"
```

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

## Examples

Reported:

{/* bad {"count": 2} */}
```js
const usage = `Write $\{name} to insert the name`;
const help = `Write \$\{name} to insert the name`;
```

Not reported:

{/* good */}
```js
const usage = `Write \${name} to insert the name`;
```

{/* good */}
```js
const pattern = String.raw`$\{name}`;
```
