The initial values of a Set list the same literal twice
What it finds
new Set(["read", "write", "read"]): a set keeps each value once, so a literal listed twice in its initial values is dropped. It is usually a copy-paste slip that hides a value that was meant instead.
The constructor must be the global Set or WeakSet, and the duplicates literals of the same value.
From the rule's source, repeated_collection_element.rs.
const modes = new Set(["read", "write", "read"]);tx0 reports: is already in this setconst ok = new Set([1, 2, 3]);const list = ["a", "a"]; Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:repeated-collection-element" = "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:repeated-collection-element] reason="..."tx0 explain tx0/ts:repeated-collection-element shows the same in the terminal. Found a false positive? Report it.