JSX accessibility
JSX accessibility rules from eslint-plugin-jsx-a11y, applied to TSX (and JSX-in-TS) sources. Checks the static structure of JSX elements against WAI-ARIA authoring guidance, interactive controls should be focusable, labels should reference a control, ARIA properties should match the element role, and so on. Runtime accessibility issues require live audits; this family catches the statically-decidable subset. Component alias settings, router-specific anchor settings, and autofixes are deferred.
Source: eslint-plugin-jsx-a11y (MIT).
jsx-a11y/alt-text: Require image-like JSX elements (<img>,<input type="image">,<object>,<area>) to expose alt text or an ARIA label.jsx-a11y/anchor-ambiguous-text: Reject<a>elements whose visible text is one of a small set of phrases that carry no information out of context.jsx-a11y/anchor-has-content: Reject empty JSX anchors with no accessible content (text,aria-label, or labelled child).jsx-a11y/anchor-is-valid: Reject anchors with missing,#-only, empty, orjavascript:hrefvalues, all of which break navigation semantics.jsx-a11y/aria-activedescendant-has-tabindex: RequiretabIndexon any element carryingaria-activedescendantunless the tag is already focusable by default (<input>, etc.).jsx-a11y/aria-props: Rejectaria-*JSX attribute names that are not part of the WAI-ARIA States and Properties spec, catches typos such asaria-labeledby(missing secondl) that silently disable assistive-tech support.jsx-a11y/aria-proptypes: Validate literal values supplied to ARIA properties against the type the spec declares for them.jsx-a11y/aria-role: Requirerolevalues to be a concrete, non-abstract WAI-ARIA role ("button","checkbox", β¦).jsx-a11y/aria-unsupported-elements: Reject ARIA roles and attributes on elements that do not support them (e.g.<meta>).jsx-a11y/autocomplete-valid: Validate the literalautocompletetoken against the HTML spec vocabulary and against thetypeof the surrounding input.jsx-a11y/click-events-have-key-events: Require keyboard handlers alongsideonClickon non-interactive JSX elements so the element is also reachable by keyboard.jsx-a11y/control-has-associated-label: Require interactive controls to have an accessible label (visible text,aria-label, oraria-labelledby).jsx-a11y/heading-has-content: Reject empty JSX headings, assistive technology cannot announce content that does not exist.jsx-a11y/html-has-lang: Require<html>JSX elements to declare a non-emptylangattribute so screen readers can pick the correct pronunciation.jsx-a11y/iframe-has-title: Require every<iframe>JSX element to declare a non-empty, uniquetitleso assistive tech can announce the embedded content.jsx-a11y/img-redundant-alt: Reject redundant words such as image, photo, or picture inside thealtattribute of an<img>. The role already conveys βthis is an imageβ.jsx-a11y/interactive-supports-focus: Require elements with interactive ARIA roles (role="button",role="link", β¦) to be focusable.jsx-a11y/label-has-associated-control: Require<label>elements to either wrap a form control or reference one viahtmlFor.jsx-a11y/label-has-for: Deprecated predecessor oflabel-has-associated-control.jsx-a11y/lang: Require the<html lang>value to be a valid IETF BCP-47 tag ("en","en-US", β¦).jsx-a11y/media-has-caption: Require<audio>and<video>elements to provide a<track kind="captions">child.jsx-a11y/mouse-events-have-key-events: RequireonMouseOver/onMouseOuthandlers to haveonFocus/onBlurparity so keyboard users get the same interaction.jsx-a11y/no-access-key: Reject theaccessKeyJSX attribute, it conflicts with assistive-technology keyboard shortcuts.jsx-a11y/no-aria-hidden-on-focusable: Rejectaria-hiddenon focusable JSX elements, focus would land on an element hidden from assistive tech.jsx-a11y/no-autofocus: RejectautoFocus/autofocusJSX attributes, they steal focus on page load and disorient keyboard users.jsx-a11y/no-distracting-elements: Reject<blink>and<marquee>, moving content cannot be paused and harms users with cognitive or visual impairments (WCAG 2.2.2).jsx-a11y/no-interactive-element-to-noninteractive-role: Reject non-interactive ARIA roles applied to natively interactive elements.jsx-a11y/no-noninteractive-element-interactions: Reject interaction event handlers (onClick,onKeyDown) placed on known non-interactive elements without a role override.jsx-a11y/no-noninteractive-element-to-interactive-role: Reject interactive ARIA roles applied to non-interactive elements.jsx-a11y/no-noninteractive-tabindex: RejecttabIndexon non-interactive JSX elements that have no interactive role.jsx-a11y/no-redundant-roles: Reject explicitroleattributes that duplicate the native semantics of the element.jsx-a11y/no-static-element-interactions: Require static elements with interaction handlers to declare an interactiverole.jsx-a11y/prefer-tag-over-role: Prefer native JSX tags overdiv/spanplus an equivalentrole.jsx-a11y/role-has-required-aria-props: Require ARIA properties that the chosen role mandates.jsx-a11y/role-supports-aria-props: Reject ARIA properties that the role does not support.jsx-a11y/scope: Restrict thescopeattribute to<th>cells.jsx-a11y/tabindex-no-positive: RejecttabIndexvalues greater than zero.
Last updated on