<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Wade H.</title>
    <description>The latest articles on DEV Community by Wade H. (@vdtdev).</description>
    <link>https://dev.to/vdtdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F663148%2F0e3b5d7e-dd1e-4690-a84d-96108532764b.png</url>
      <title>DEV Community: Wade H.</title>
      <link>https://dev.to/vdtdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vdtdev"/>
    <language>en</language>
    <item>
      <title>Angular A11y ESLint Rules</title>
      <dc:creator>Wade H.</dc:creator>
      <pubDate>Wed, 17 Nov 2021 21:33:55 +0000</pubDate>
      <link>https://dev.to/bitovi/angular-a11y-eslint-rules-2fjc</link>
      <guid>https://dev.to/bitovi/angular-a11y-eslint-rules-2fjc</guid>
      <description>&lt;p&gt;Making a web application accessible can feel like a daunting task, particularly if you aren't used to taking accessibility into consideration.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/angular-eslint/angular-eslint"&gt;&lt;code&gt;@angular-eslint&lt;/code&gt;&lt;/a&gt; repo includes a number of linting rules that can help enforce accessibility best practices within Angular component templates.&lt;/p&gt;

&lt;p&gt;It is important to note, however, that these rules do not check attributes and roles set using the host section of the &lt;code&gt;@Component&lt;/code&gt; decorator, or ones set using &lt;code&gt;@HostBinding&lt;/code&gt; decorators.&lt;/p&gt;

&lt;p&gt;While passing these rules isn't a guarantee or metric for ensuring full accessibility, it is a step in the right direction.&lt;/p&gt;

&lt;p&gt;For convenience, I've divided the rules I will be covering into three groups. The first group, general, covers ARIA roles and attributes. The second group, content, includes rules related to textual representations of content. The last group, interactivity, includes rules pertaining to user interaction and event handling. &lt;/p&gt;

&lt;h2&gt;
  
  
  General Rules
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;@angular-eslint/template/accessibility-valid-aria&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This rule makes sure that all &lt;code&gt;aria-*&lt;/code&gt; attributes used are valid. The rule will fail if a non-existent &lt;code&gt;aria-*&lt;/code&gt; attribute is used, or a valid &lt;code&gt;aria-*&lt;/code&gt; attribute is given an unexpected value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin-template/src/rules/accessibility-valid-aria.ts"&gt;Rule Source&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Content Rules
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;@angular-eslint/template/accesssibility-alt-text&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Checks visual elements &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;object&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;area&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; (of type &lt;code&gt;'image'&lt;/code&gt;) to make sure they have descriptive text. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; elements must have an &lt;code&gt;alt&lt;/code&gt; attribute&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;object&amp;gt;&lt;/code&gt; elements must have either a &lt;code&gt;title&lt;/code&gt; or &lt;code&gt;aria-label&lt;/code&gt; attribute&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;area&amp;gt;&lt;/code&gt; elements must have either an &lt;code&gt;alt&lt;/code&gt; or &lt;code&gt;aria-label&lt;/code&gt; attribute&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; elements with &lt;code&gt;type='image'&lt;/code&gt; must have either an &lt;code&gt;alt&lt;/code&gt; or &lt;code&gt;aria-label&lt;/code&gt; attribute&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin-template/src/rules/accessibility-alt-text.ts"&gt;Rule Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Related Guidelines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/TR/WCAG21/#text-alternatives"&gt;WCAG Guideline 1.1 - Text Alternatives&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;@angular-eslint/template/accessibility-elements-content&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Checks heading, anchor and button elements to make sure they contain accessible content. This can be in the form of text, binding to &lt;code&gt;[innerText]&lt;/code&gt;, &lt;code&gt;[innerHtml]&lt;/code&gt; or &lt;code&gt;[outerHTML]&lt;/code&gt;, or use of &lt;code&gt;aria-label&lt;/code&gt; or &lt;code&gt;title&lt;/code&gt; attributes. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin-template/src/rules/accessibility-elements-content.ts"&gt;Rule Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Related guidelines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/WCAG21/quickref/?showtechniques=2410%2C253%2C246#headings-and-labels"&gt;WCAG Guidelines 2.4.6 - Headings and Labels&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/WCAG21/quickref/?showtechniques=246%2C2410%2C253#info-and-relationships"&gt;WCAG Guidelines 1.3.1 - Info and Relationships&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;@angular-eslint/template/accessibility-label-for&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Check that label elements and label components are associated with form elements.&lt;/p&gt;

&lt;p&gt;Default behavior expects &lt;code&gt;label&lt;/code&gt; elements to either be associated with an input element via the &lt;code&gt;for&lt;/code&gt; attribute, or to contain a &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;meter&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;output&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;progress&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;, or &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;Configuration Options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"controlComponents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"labelComponents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"labelAttributes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;controlComponents&lt;/code&gt; - Specify  components to treat as input elements (in addition to ones mentioned above)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;labelComponents&lt;/code&gt; - Specify components to treat as label elements (in addition to &lt;code&gt;label&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;labelAttributes&lt;/code&gt; - Specify attributes that can satisfy label being associated with an input element (in addition to &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;htmlFor&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin-template/src/rules/accessibility-label-for.ts"&gt;Rule Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Related guidelines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/WCAG21/quickref/?showtechniques=131%2C132%2C246%2C2410%2C253%2C332%2C136#info-and-relationships"&gt;WCAG Guidelines 1.3.1 - Info and Relationships&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/WCAG21/quickref/?showtechniques=131%2C136%2C246%2C2410%2C253%2C332#labels-or-instructions"&gt;WCAG Guidelines 3.3.2 - Labels or Instructions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Interactivity Rules
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;@angular-eslint/template/no-positive-tabindex&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This rule checks to make sure &lt;code&gt;tabindex&lt;/code&gt; is only ever being set to &lt;code&gt;0&lt;/code&gt; (element is tab focusable) or &lt;code&gt;-1&lt;/code&gt; (element is not tab focusable), and not a positive value that interferes with the automatic tab order of elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin-template/src/rules/no-positive-tabindex.ts"&gt;Rule Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Related Guidelines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/WCAG21/quickref/?showtechniques=131%2C132%2C136%2C211%2C246%2C2410%2C253%2C332#focus-order"&gt;WCAG Guidelines 2.4.3 - Focus Order&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;@angular-eslint/template/click-events-have-key-events&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Requires elements with click event handlers also handle at least one key event (&lt;code&gt;keyup&lt;/code&gt;, &lt;code&gt;keydown&lt;/code&gt; or &lt;code&gt;keypress&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin-template/src/rules/click-events-have-key-events.ts"&gt;Rule Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Related Guidelines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/WCAG21/quickref/?showtechniques=131%2C132%2C136%2C211%2C246%2C2410%2C253%2C332#keyboard-accessible"&gt;WCAG Guidelines 2.1 - Keyboard Accessible&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;@angular-eslint/template/mouse-events-have-key-events&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Requires any element with a &lt;code&gt;mouseout&lt;/code&gt; event handler to also handle &lt;code&gt;blur&lt;/code&gt; events, and any element with a &lt;code&gt;mouseover&lt;/code&gt; event handler to also handle &lt;code&gt;focus&lt;/code&gt; events.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin-template/src/rules/mouse-events-have-key-events-rule.ts"&gt;Rule Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Related Guidelines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/WCAG21/quickref/?showtechniques=131%2C132%2C136%2C211%2C246%2C2410%2C253%2C332#keyboard-accessible"&gt;WCAG Guidelines 2.1 - Keyboard Accessible&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Passing these rules is an easy way to start the journey of making your Angular applications accessible, and hopefully encourage you to consider accessibility as you develop. &lt;/p&gt;

&lt;p&gt;Additional Reading:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://angular.io/guide/accessibility"&gt;Angular.io - Accessibility in Angular&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codelabs.developers.google.com/angular-a11y#0"&gt;Google CodeLabs - Build more accessible Angular apps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.google.com/web/fundamentals/accessibility"&gt;Accessibility | Web Fundamentals&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://accessibility.digital.gov/front-end/getting-started/"&gt;Digital.gov - Accessibility for front-end developers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>angular</category>
      <category>a11y</category>
    </item>
  </channel>
</rss>
