JavaScript

JavaScript

Made by DeepSource

Useless template literal found JS-R1004

Anti-pattern
Minor
Autofix

Template literals are useful when you need:

  1. Interpolated strings.

  2. Strings that have unescaped double quotes and single quotes.

  3. Strings that need line breaks in them.

If neither of these three conditions is met, you can replace the template expression with a regular string literal.

Bad Practice

const dialogue = `"Journey before destination", said Dalinar.`
const dialogue2 = `What is a 'Kwisatz Haderach'?`

Recommended

const dialogue = '"Journey before destination", said Dalinar.'
const dialogue2 = "What is a 'Kwisatz Haderach'?"
const dialogue3 = `"${getLine()}", said ${getChararcter()}`