The same string literal is written more often than the configured maximum in a file
What it finds
The same string written many times in a file, such as an event name, a CSS class or an error message, has to be changed in every place at once, and a typo in one of them goes unnoticed. A named constant keeps one copy.
String literals of at least ten characters are counted per file, except module names in imports and exports, literal types and JSX attribute values. A string that appears more often than the parameter max allows (2 by default) is reported once, at its first occurrence.
From the rule's source, duplicate_string.rs.
export function events(on: (name: string) => void) { on("user-signed-in");tx0 reports: this string is written 3 times on("user-signed-in"); on("user-signed-in"); on("short"); on("short"); on("short");} 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:duplicate-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:duplicate-string] reason="..."tx0 explain tx0/ts:duplicate-string shows the same in the terminal. Found a false positive? Report it.