Disallow unnecessary concatenation of literals or template literals
It’s unnecessary to concatenate two strings together, such as:
This code is likely the result of refactoring where a variable was removed from the concatenation (such as "a" + b + "b"
). In such a case, the concatenation isn’t important and the code can be rewritten as:
This rule aims to flag the concatenation of 2 literals when they could be combined into a single literal. Literals can be strings or template literals.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
If you don’t want to be notified about unnecessary string concatenation, you can safely disable this rule.
This rule was introduced in ESLint v1.3.0.
© OpenJS Foundation and other contributors
Licensed under the MIT License.
https://eslint.org/docs/latest/rules/no-useless-concat