A string with quotes contains a ${...} placeholder, which is not replaced

tx0/ts:template-in-stringstrictwarningbug

What it finds

"Hello ${name}": placeholders are only replaced in template literals, written with backticks. In a string with quotes, ${name} is kept as it is.

A string is reported when it contains ${ followed by a name or a member access and a closing }, as a placeholder would be written. Some libraries use the same syntax for templates of their own that they fill in later, as editors and build tools do for their variables, which is why the rule is strict.

From the rule's source, template_in_string.rs.

Example from the rule's tests
function greet(name: string, user: { id: number }) {  const a = "Hello ${name}";tx0 reports: this string contains a placeholder that is not replaced  const b = 'User ${user.id}';tx0 reports: this string contains a placeholder  const c = `Hello ${name}`;  const d = "costs $5 {total}";  return [a, b, c, d];}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

tx0.toml
[rules]
"tx0/ts:template-in-string" = "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:template-in-string] reason="..."

tx0 explain tx0/ts:template-in-string shows the same in the terminal. Found a false positive? Report it.