A property with a plain name is read with brackets and a string
What it finds
user["name"] reads a property whose name is a plain identifier, which user.name writes shorter and lets editors and the compiler follow.
Reported are element accesses with a string literal key that is a valid identifier and not a reserved word. In TypeScript, index signatures sometimes require the bracket form under noPropertyAccessFromIndexSignature, which is why this is a strict rule. The fix, which is safe, writes the dot form.
From the rule's source, quoted_member_access.rs.
export function read(user: Record<string, string>) { const a = user["name"];tx0 reports: can be written .name const b = user["first-name"]; const c = user?.["id"];tx0 reports: can be written .id return [a, b, c];} 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:quoted-member-access" = "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:quoted-member-access] reason="..."tx0 explain tx0/ts:quoted-member-access shows the same in the terminal. Found a false positive? Report it.