Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 2.23 KB

File metadata and controls

75 lines (51 loc) · 2.23 KB

ember/template-no-redundant-role

💼 This rule is enabled in the following configs: ✅ recommended, strict-gjs, strict-gts.

🔧 This rule is automatically fixable by the --fix CLI option.

Disallows redundant role attributes on semantic HTML elements.

The rule checks for redundancy between any semantic HTML element with a default/implicit ARIA role and the role provided.

For example, if a landmark element is used, any role provided will either be redundant or incorrect. This rule ensures that no role attribute is placed on any of the landmark elements, with the following exceptions:

Examples

This rule forbids the following:

<header role='banner'></header>
<main role='main'></main>
<aside role='complementary'></aside>
<footer role='contentinfo'></footer>
<form role='form'></form>

This rule allows the following:

<form role='search'></form>
<nav role='navigation'></nav>
<input role='combobox' />

Configuration

This rule accepts an options object with the following properties:

  • checkAllHTMLElements (default: true) - When set to true, checks all HTML elements for redundant roles. When false, only checks landmark elements.
// .eslintrc.js
module.exports = {
  rules: {
    'ember/template-no-redundant-role': ['error', { checkAllHTMLElements: false }],
  },
};

References