Skip to content

Latest commit

Β 

History

History
31 lines (20 loc) Β· 1.03 KB

File metadata and controls

31 lines (20 loc) Β· 1.03 KB

consistent-template-literal-escape

πŸ“ Enforce consistent style for escaping ${ in template literals.

πŸ’ΌπŸš« This rule is enabled in the βœ… recommended config. This rule is disabled in the β˜‘οΈ unopinionated config.

πŸ”§ This rule is automatically fixable by the --fix CLI option.

There are multiple ways to escape ${ in a template literal to prevent it from being interpreted as an expression:

  • \${ β€” escape the dollar sign βœ…
  • $\{ β€” escape the opening brace ❌
  • \$\{ β€” escape both ❌

This rule enforces escaping the dollar sign (\${) for consistency.

Examples

// ❌
const foo = `$\{a}`;

// ❌
const foo = `\$\{a}`;

// βœ…
const foo = `\${a}`;