# consistent-template-literal-escape πŸ“ Enforce consistent style for escaping `${` in template literals. πŸ’ΌπŸš« This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). This rule is _disabled_ in the β˜‘οΈ `unopinionated` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). πŸ”§ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). When you need to include a literal `${` in a template literal (without it being interpreted as the start of an interpolation), there are multiple ways to escape it. This rule enforces using `\${` (escaping the dollar sign) for consistency, as it's the most intuitive and clearest approach. ## Escaping methods - `\${` β€” escape the dollar sign βœ… (recommended) - `$\{` β€” escape the opening brace (works, but inconsistent) - `\$\{` β€” escape both (redundant) ## Examples ```js // ❌ - Escaping the brace is inconsistent const template = `$\{variableName}`; // ❌ - Escaping both is redundant const template = `\$\{variableName}`; // βœ… - Escape the dollar sign const template = `\${variableName}`; ``` ```js // βœ… - Common use case: template strings for users const message = `Use \${variable} in your code`; // βœ… - JavaScript regex pattern const regex = `/\${pattern}/g`; ``` ```js // βœ… - Normal variable interpolation still works const name = 'Alice'; const greeting = `Hello ${name}, use \${variable} for templates`; // β†’ "Hello Alice, use ${variable} for templates" ```