A [...] set in a pattern lists one character twice
What it finds
/[a-zA-Z_a]/, /[.,;.]/: a character that a class already contains, alone or in a range, adds nothing when it is listed again. It often shows a typo, as [A-z] for [A-Za-z] would, or a range that is wider than meant.
Characters and ranges are compared as written; classes such as \d are not expanded. Letters are compared with their case, also under the i flag.
From the rule's source, set_lists_character_twice.rs.
const a = /[a-zA-Z_a]/;tx0 reports: a character class in this pattern contains a more than onceconst b = /[.,;.]/;tx0 reports: contains . more than onceconst c = /[a-z0-9_-]/;const d = /[A-Za-z]/i; 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:set-lists-character-twice" = "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:set-lists-character-twice] reason="..."tx0 explain tx0/ts:set-lists-character-twice shows the same in the terminal. Found a false positive? Report it.