Skip to main content

noUnusedTemplateLiteral

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

Examples

Invalid

const foo = `bar`
warning[noUnusedTemplateLiteral]: Do not use template literals if interpolation and special-character handling are not needed.
   noUnusedTemplateLiteral.js:1:13
  
1  const foo = `bar`
               -----

Suggested fix: Replace with string literal
    | @@ -1 +1 @@
0   | - const foo = `bar`
  0 | + const foo = "bar"

const foo = `bar `
warning[noUnusedTemplateLiteral]: Do not use template literals if interpolation and special-character handling are not needed.
   noUnusedTemplateLiteral.js:1:13
  
1  const foo = `bar `
               ------

Suggested fix: Replace with string literal
    | @@ -1 +1 @@
0   | - const foo = `bar `
  0 | + const foo = "bar "

Valid

const foo = `bar
has newline
`
;
const foo = `"bar"`
const foo = `'bar'`