An object property repeats the name of the variable that gives its value
What it finds
{ name: name } repeats a name where the shorthand { name } says the same: a property that takes its value from the variable of the same name.
The property __proto__ is left alone, since { __proto__: x } sets the prototype and the shorthand creates an ordinary property. The fix, which is safe, writes the shorthand.
From the rule's source, object_shorthand.rs.
export function make(name: string, age: number, __proto__: object) { return { name: name, years: age, age, __proto__: __proto__ };tx0 reports: name: name can be written name} 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:object-shorthand" = "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:object-shorthand] reason="..."tx0 explain tx0/ts:object-shorthand shows the same in the terminal. Found a false positive? Report it.