prefer-template
eslint
Safe autofix
eslint.config.js
export default [
{
rules: {
"prefer-template": "error",
},
},
];const str = "Hello, " + name + "!";
const str1 = "Time: " + (12 * 60 * 60 * 1000);const str = "Hello World!";
const str1 = `Hello, ${name}!`;
const str2 = `Time: ${12 * 60 * 60 * 1000}`;
// This is reported by `no-useless-concat`.
const str4 = "Hello, " + "World!";Examples from the ESLint documentation.
prefer-template
eslint
export default [
{
rules: {
"prefer-template": "error",
},
},
];prefer-template
eslint plugin · style
{
"rules": {
"prefer-template": "error"
}
}style/useTemplate
style · since 1.0.0
{
"linter": {
"rules": {
"style": {
"useTemplate": "error"
}
}
}
}Require template literals instead of string concatenation in <template>
Disallow returning value from constructor
Disallow the use of Math.pow in favor of the ** operator
Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals
Enforce the use of the radix argument when using parseInt()
Disallow variable or function declarations in nested blocks