mouse-events-have-key-events
Angular templatesHTMLVue / SvelteVue / Sveltecorrectnessno fixdefault: offhtml/angular-eslint-recommended
What it does
Section titled “What it does”Reports a mouseover handler with no focus handler and a mouseout handler with no blur handler on the same element.
Why it matters
Section titled “Why it matters”Content that appears or changes on hover is out of reach for a keyboard user unless the same happens on focus. Pairing mouseover with focus and mouseout with blur gives both users the same behavior.
Example
Section titled “Example”...<app-card (click)="a()"></app-card><div role="heading" (keydown)="a()"></div>@if (ok) { <div (click)="a()" aria-hidden="true"></div> }<div (mouseover)="a()"></div><div (mouseout)="a()" (blur)="b()"></div>...<input id="a" /> <label for="a">Name</label> <label [for]="id">Name</label> <label><input /></label>...Configuration
Section titled “Configuration”angular: lint: rules: mouse-events-have-key-events: warn # off (default), warn, errorhtml: lint: rules: mouse-events-have-key-events: warn # off (default), warn, errorsvelte: lint: rules: mouse-events-have-key-events: warn # off (default), warn, errorvue: lint: rules: mouse-events-have-key-events: warn # off (default), warn, errorEnabled by the presets: html/angular-eslint-recommended.
Suppress one line with sudsy-disable-next-line mouse-events-have-key-events in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| angular-eslint | mouse-events-have-key-events |
full |