Skip to content

noUnusedTemplateLiteral (since v1.0.0)

Diagnostic Category: lint/style/noUnusedTemplateLiteral

Sources:

Disallow template literals if interpolation and special-character handling are not needed

const foo = `bar`
style/noUnusedTemplateLiteral.js:1:13 lint/style/noUnusedTemplateLiteral  FIXABLE  ━━━━━━━━━━━━━━━━━

   Do not use template literals if interpolation and special-character handling are not needed.
  
  > 1 │ const foo = `bar`
               ^^^^^
    2 │ 
  
   Unsafe fix: Replace with string literal
  
    1  - const·foo·=·`bar`
      1+ const·foo·=·"bar"
    2 2  
  
const foo = `bar `
style/noUnusedTemplateLiteral.js:1:13 lint/style/noUnusedTemplateLiteral  FIXABLE  ━━━━━━━━━━━━━━━━━

   Do not use template literals if interpolation and special-character handling are not needed.
  
  > 1 │ const foo = `bar `
               ^^^^^^
    2 │ 
  
   Unsafe fix: Replace with string literal
  
    1  - const·foo·=·`bar·`
      1+ const·foo·=·"bar·"
    2 2  
  
const foo = `bar
has newline`;
const foo = `"bar"`
const foo = `'bar'`