Skip to main content

no-useless-template-literals

Disallow unnecessary template expressions.

🔧

Some problems reported by this rule are automatically fixable by the --fix ESLint command line option.

💭

This rule requires type information to run.

This rule reports template literals that contain substitution expressions (also variously referred to as embedded expressions or string interpolations) that are unnecessary and can be simplified.

warning

This rule is being renamed to no-unnecessary-template-expression. The current name, no-useless-template-literals, will be removed in a future major version of typescript-eslint.

After the creation of this rule, it was realized that the name no-useless-template-literals could be misleading, seeing as this rule only targets template literals with substitution expressions. In particular, it does not aim to flag useless template literals that look like `this` and could be simplified to "this". If you are looking for such a rule, you can configure the @stylistic/ts/quotes rule to do this.

.eslintrc.cjs
module.exports = {
"rules": {
"@typescript-eslint/no-useless-template-literals": "error"
}
};

Try this rule in the playground ↗

Options​

This rule is not configurable.

When Not To Use It​

Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting. See Performance Troubleshooting if you experience performance degredations after enabling type checked rules.

Resources​