Strings are joined with values by + where a template literal would read better
What it finds
"Hello " + name + ", you have " + count + " messages" alternates quotes and plus signs, so spaces at the seams are easily lost. A template literal, ` Hello ${name}, you have ${count} messages `, shows the resulting text in one piece.
A chain of + is reported once, where it starts, when it joins at least one string literal with at least one value that is not a literal.
From the rule's source, concat_instead_of_template.rs.
export function greet(name: string, count: number) { const a = "Hello " + name + ", you have " + count + " messages";tx0 reports: joins strings and values const b = "a" + "b"; const c = count + 1; return [a, b, c];} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:concat-instead-of-template" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:concat-instead-of-template] reason="..."tx0 explain tx0/ts:concat-instead-of-template shows the same in the terminal. Found a false positive? Report it.