A generic <div> or <span> is given a role that an HTML element provides with its behaviour

tx0/ts:role-instead-of-elementstrictwarningaccessibility/webdepth fastsmell

What it finds

<div role="button"> announces a button but behaves like none: it is not focusable, does not react to Enter or Space and is not disabled by disabled. The element that has the role natively brings all of that.

Reported are <div> and <span> elements with one of the roles button, checkbox, link, heading, img, list, listitem, navigation, main, table, textbox, radio, separator, progressbar, slider, dialog, article and figure.

From the rule's source, role_instead_of_element.rs.

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:

tx0.toml
[rules]
"tx0/ts:role-instead-of-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:role-instead-of-element] reason="..."

tx0 explain tx0/ts:role-instead-of-element shows the same in the terminal. Found a false positive? Report it.