ECMAScript 2015 added the ability to use template literals instead of concatenation. Since their use is clearer and more concise, they are preferred.
This rule raises an issue when a string is created from the result of two or more concatenations.
function sayHello(name) { console.log("hello " + name); // ignored } function madLib(verb, noun) { console.log("I really " + verb + " one or two " + noun); // Noncompliant }
function sayHello(name) { console.log(`hello ${name}`); // no issue raised before, but this is better } function madLib(verb, noun) { console.log(`I really ${verb} one or two ${noun}`); }