close

consistent-template-literal-escape

Added in v0.9.4

Configuration

PresetConfigured Value
✅ unicornPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/consistent-template-literal-escape': 'error',
    },
  },
]);

Enforce one consistent way to escape a literal ${ sequence inside template literals.

Use \${ by escaping the dollar sign rather than escaping the opening brace.

// Incorrect
const template = `$\{variableName}`;
const redundant = `\$\{variableName}`;

// Correct
const template = `\${variableName}`;

Tagged templates are ignored because tags can observe the raw template text.

The rule is automatically fixable and preserves the surrounding template delimiters and interpolation boundaries.

This port follows eslint-plugin-unicorn v75.0.0.