A computed property name is a literal written in brackets
What it finds
{ ["name"]: value } computes a key that is already written out: the brackets add nothing to { "name": value } but make the reader look for an expression.
Computed names that are a string or number literal are reported, in object literals and classes. The names constructor, prototype and __proto__ are left alone, since writing them plainly changes their meaning: "constructor"() {} in a class is the constructor, ["constructor"]() {} a method. The fix, which is safe, removes the brackets.
From the rule's source, redundant_computed_key.rs.
export const a = { ["name"]: 1, [key]: 4 };tx0 reports: computes a keyexport class K { ["constructor"]() { return 1; }}declare const key: string; 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:redundant-computed-key" = "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:redundant-computed-key] reason="..."tx0 explain tx0/ts:redundant-computed-key shows the same in the terminal. Found a false positive? Report it.