Repository: GoogleChrome/lighthouse
Pull request #5764 (2018-08-01 19:06:15)

new_audit: add a11y manual audit for interactive element affordance
**Summary**
Add new a11y manual audit for interactive element affordance

New feature

Forgetting to provide affordances for links and buttons is a common web accessibility issue that is often overlooked because it is a manual check. In preparation for adding this audit, I already added corresponding documentation to the Google Web Fundamentals "[How To Do an Accessibility Review](https://developers.google.com/web/fundamentals/accessibility/how-to-review#interactive_elements_like_links_and_buttons_should_indicate_their_purpose_and_state)" page.   https://github.com/google/WebFundamentals/pull/6384

**Related Issues/PRs**
https://github.com/GoogleChrome/lighthouse/issues/5667



robdodson: lgtm
paulirish: thanks @joelhsmith this is great. :D 

Patch:
diff --git a/lighthouse-core/audits/accessibility/manual/interactive-element-affordance.js b/lighthouse-core/audits/accessibility/manual/interactive-element-affordance.js
new file mode 100644
index 000000000..309a1fd64
--- /dev/null
+++ b/lighthouse-core/audits/accessibility/manual/interactive-element-affordance.js
@@ -0,0 +1,28 @@
+
+/**
+ * @license Copyright 2018 Google Inc. All Rights Reserved.
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+ */
+'use strict';
+
+const ManualAudit = require('../../manual/manual-audit');
+
+/**
+ * @fileoverview Manual A11y audit for interactive element affordance.
+ */
+
+class InteractiveElementAffordance extends ManualAudit {
+  /**
+   * @return {LH.Audit.Meta}
+   */
+  static get meta() {
+    return Object.assign({
+      id: 'interactive-element-affordance',
+      description: 'Interactive elements, such as links and buttons, should indicate their state and be distinguishable from non-interactive elements. [Learn more](https://developers.google.com/web/fundamentals/accessibility/how-to-review#interactive_elements_like_links_and_buttons_should_indicate_their_purpose_and_state).',
+      title: 'Interactive elements indicate their purpose and state',
+    }, super.partialMeta);
+  }
+}
+
+module.exports = InteractiveElementAffordance;
diff --git a/lighthouse-core/config/default-config.js b/lighthouse-core/config/default-config.js
index 5521c28f5..f582044cf 100644
--- a/lighthouse-core/config/default-config.js
+++ b/lighthouse-core/config/default-config.js
@@ -171,6 +171,7 @@ module.exports = {
     'accessibility/manual/focus-traps',
     'accessibility/manual/focusable-controls',
     'accessibility/manual/heading-levels',
+    'accessibility/manual/interactive-element-affordance',
     'accessibility/manual/logical-tab-order',
     'accessibility/manual/managed-focus',
     'accessibility/manual/offscreen-content-hidden',
@@ -382,6 +383,7 @@ module.exports = {
         // Manual audits
         {id: 'logical-tab-order', weight: 0},
         {id: 'focusable-controls', weight: 0},
+        {id: 'interactive-element-affordance', weight: 0},
         {id: 'managed-focus', weight: 0},
         {id: 'focus-traps', weight: 0},
         {id: 'custom-controls-labels', weight: 0},


Test patch:
diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json
index 7d695dc79..1684db5ca 100644
--- a/lighthouse-core/test/results/sample_v2.json
+++ b/lighthouse-core/test/results/sample_v2.json
@@ -1624,6 +1624,14 @@
       "scoreDisplayMode": "manual",
       "rawValue": false
     },
+    "interactive-element-affordance": {
+      "id": "interactive-element-affordance",
+      "title": "Interactive elements indicate their purpose and state",
+      "description": "Interactive elements, such as links and buttons, should indicate their state and be distinguishable from non-interactive elements. [Learn more](https://developers.google.com/web/fundamentals/accessibility/how-to-review#interactive_elements_like_links_and_buttons_should_indicate_their_purpose_and_state).",
+      "score": null,
+      "scoreDisplayMode": "manual",
+      "rawValue": false
+    },
     "logical-tab-order": {
       "id": "logical-tab-order",
       "title": "The page has a logical tab order",
@@ -3157,6 +3165,10 @@
           "id": "focusable-controls",
           "weight": 0
         },
+        {
+          "id": "interactive-element-affordance",
+          "weight": 0
+        },
         {
           "id": "managed-focus",
           "weight": 0