ember/template-require-mandatory-role-attributes

April 25, 2026 ยท View on GitHub

๐Ÿ’ผ This rule is enabled in the ๐Ÿ“‹ template-lint-migration config.

Elements with ARIA roles must also include all required attributes for that role. This ensures that a given element possesses the necessary states and properties to behave consistently with user expectations for other elements with the same ARIA role.

This rule enforces that elements with an ARIA role also declare all required ARIA attributes for that role.

Examples

This rule forbids the following:

<template>
  <div role="option" />
  <CustomComponent role="checkbox" aria-required="true" />
  {{some-component role="heading"}}
</template>

This rule allows the following:

<template>
  <div role="option" aria-selected="false" />
  <CustomComponent role="checkbox" aria-required="true" aria-checked="false" />
  {{some-component role="heading" aria-level="2"}}

  {{! Native inputs supply required ARIA state for matching roles. Lookup is
      based on axobject-query's elementAXObjects + AXObjectRoles (see below). }}
  <input type="checkbox" role="switch" />
  <input type="checkbox" role="checkbox" />
  <input type="radio" role="radio" />
  <input type="range" role="slider" />
</template>

Semantic-role exemptions

When the role attribute explicitly declares a role that the native element already provides, the native element supplies the required ARIA state and the rule does not flag missing attributes. The exemption is looked up via axobject-query's elementAXObjects + AXObjectRoles maps, matching the approach used by eslint-plugin-jsx-a11y and @angular-eslint/template.

Exempt pairings include (non-exhaustive):

ElementRoleRequired ARIA state supplied by
<input type="checkbox">checkbox, switchnative checked state
<input type="radio">radionative checked state
<input type="range">slidernative value / min / max
<input type="number">spinbuttonnative value / min / max (spinbutton's required aria-valuenow is derived from the native value)
<input type="text">textboxno required ARIA
<input type="search">searchboxno required ARIA

Undocumented pairings (e.g. <input type="checkbox" role="menuitemcheckbox"> โ€” axobject-query does not list this) remain flagged.

References