no-redundant-role
What it does
Section titled “What it does”Reports a role on an element that already has that role by its name (<nav role="navigation">, <button role="button">, <ul role="list">).
Why it matters
Section titled “Why it matters”The role adds nothing and can only fall out of step with the element: when the element is later changed to another one, the old role overrides the native meaning.
To fix, remove the role.
Example
Section titled “Example”<!DOCTYPE html><title>x</title><nav role="navigation"></nav><button role="button">x</button><a href="x" role="link">x</a><a role="link">x</a><ul role="list"></ul><div role="navigation"></div>...<p role="none"></p>Configuration
Section titled “Configuration”angular: lint: rules: no-redundant-role: warn # off (default), warn, errorhtml: lint: rules: no-redundant-role: warn # off (default), warn, errorsvelte: lint: rules: no-redundant-role: warn # off (default), warn, errorvue: lint: rules: no-redundant-role: warn # off (default), warn, errorEnabled by the presets: html/html-validate-recommended.
Suppress one line with sudsy-disable-next-line no-redundant-role in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| html-eslint | no-redundant-role |
full | |
| html-validate | no-redundant-role |
partial | the roles of 19 elements that always have the role, and img with a non-empty alt; the conditional implicit roles (<input> by type, <select>, <li>, <section>) are not checked |