Skip to content

eslint/no-template-curly-in-string Style

🚧 An auto-fix is still under development.

What it does

Disallow template literal placeholder syntax in regular strings

Why is this bad?

ECMAScript 6 allows programmers to create strings containing variable or expressions using template literals, instead of string concatenation, by writing expressions like ${variable} between two backtick quotes. It can be easy to use the wrong quotes when wanting to use template literals, by writing "${variable}", and end up with the literal value "${variable}" instead of a string containing the value of the injected expressions.

Example

Examples of incorrect code for this rule:

javascript
/*eslint no-template-curly-in-string: "error"*/
"Hello ${name}!";
"Hello ${name}!";
"Time: ${12 * 60 * 60 * 1000}";

References

Released under the MIT License.