The initial values of a Set list the same literal twice

tx0/ts:repeated-collection-elementrecommendedwarningsmell

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.

Example from the rule's tests
const modes = new Set(["read", "write", "read"]);tx0 reports: is already in this setconst ok = new Set([1, 2, 3]);const list = ["a", "a"];
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 recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

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.