A template literal is inside a substitution of another
What it finds
A template literal inside a substitution of another, as in ` a ${b ? c${d} : ''} `, nests quotes and braces so that it is hard to see where each string ends. Building the inner string first, in a variable, reads more easily.
Only a template directly inside the substitution of another is reported, not one inside a function or a tagged template there, which are separate pieces of code.
From the rule's source, template_in_template.rs.
function render(name: string, count: number) { const a = `Hello ${count > 1 ? `${count} people` : name}`;tx0 reports: nested in a substitution const b = `Hello ${name}`; const c = `List: ${[1, 2].map((n) => `${n}`).join()}`; 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:template-in-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:template-in-template] reason="..."tx0 explain tx0/ts:template-in-template shows the same in the terminal. Found a false positive? Report it.