From 951feeae4eb5285539080e9dcdd558571e9ef19f Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:18:50 -0400 Subject: [PATCH 01/19] bump aria-query to 5.3.0 --- package-lock.json | 31 ++++++++++++++++++++++--------- package.json | 2 +- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index c6157798..93a2cbd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@github/browserslist-config": "^1.0.0", "@typescript-eslint/eslint-plugin": "^5.1.0", "@typescript-eslint/parser": "^5.1.0", - "aria-query": "^5.1.3", + "aria-query": "^5.3.0", "eslint-config-prettier": ">=8.0.0", "eslint-plugin-escompat": "^3.3.3", "eslint-plugin-eslint-comments": "^3.2.0", @@ -682,11 +682,11 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/aria-query": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", - "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", "dependencies": { - "deep-equal": "^2.0.5" + "dequal": "^2.0.3" } }, "node_modules/array-includes": { @@ -1182,6 +1182,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "engines": { + "node": ">=6" + } + }, "node_modules/diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -4944,11 +4952,11 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "aria-query": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", - "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", "requires": { - "deep-equal": "^2.0.5" + "dequal": "^2.0.3" } }, "array-includes": { @@ -5298,6 +5306,11 @@ "object-keys": "^1.1.1" } }, + "dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==" + }, "diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", diff --git a/package.json b/package.json index c8f8e0d1..50151ced 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@github/browserslist-config": "^1.0.0", "@typescript-eslint/eslint-plugin": "^5.1.0", "@typescript-eslint/parser": "^5.1.0", - "aria-query": "^5.1.3", + "aria-query": "^5.3.0", "eslint-config-prettier": ">=8.0.0", "eslint-plugin-escompat": "^3.3.3", "eslint-plugin-eslint-comments": "^3.2.0", From 95c60cf78628d7ae56b813b41593af591ce04794 Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:20:48 -0400 Subject: [PATCH 02/19] Don't delete all of attributes --- lib/rules/role-supports-aria-props.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rules/role-supports-aria-props.js b/lib/rules/role-supports-aria-props.js index 55644c1f..370bb696 100644 --- a/lib/rules/role-supports-aria-props.js +++ b/lib/rules/role-supports-aria-props.js @@ -9,7 +9,10 @@ const elementRolesMap = new ObjectMap() for (const [key, value] of elementRoles.entries()) { // - Remove unused `constraints` key delete key.constraints - key.attributes = key.attributes?.filter(attribute => !('constraints' in attribute)) + // - Remove `constraints` key within `attributes` + for (const attribute of key.attributes || []) { + delete attribute.constraints + } // - Remove empty `attributes` key if (!key.attributes || key.attributes?.length === 0) { delete key.attributes From 762f7e123f2074c542874c8d7e2a47e0e14dad76 Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:36:44 -0400 Subject: [PATCH 03/19] `a` and `area` without `href` are now generic, - generic does not list `aria-checked`. --- tests/role-supports-aria-props.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/role-supports-aria-props.js b/tests/role-supports-aria-props.js index c0676d6a..1858b9cf 100644 --- a/tests/role-supports-aria-props.js +++ b/tests/role-supports-aria-props.js @@ -57,9 +57,6 @@ ruleTester.run('role-supports-aria-props', rule, { {code: ''}, {code: ''}, - // this will have global - {code: ''}, - // AREA TESTS - implicit role is `link` {code: ''}, {code: ''}, @@ -78,9 +75,6 @@ ruleTester.run('role-supports-aria-props', rule, { {code: ''}, {code: ''}, - // this will have global - {code: ''}, - // LINK TESTS - implicit role is `link` {code: ''}, {code: ''}, @@ -348,6 +342,14 @@ ruleTester.run('role-supports-aria-props', rule, { invalid: [ // implicit basic checks + { + code: '', + errors: [getErrorMessage('aria-checked', 'generic')], + }, + { + code: '', + errors: [getErrorMessage('aria-checked', 'generic')], + }, { code: '', errors: [getErrorMessage('aria-checked', 'link')], From 2747f2da177afd2255b0ed73f09546a0f238b535 Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:39:59 -0400 Subject: [PATCH 04/19] link tag maps to nothing - according to https://www.w3.org/TR/html-aam-1.0/, link tag doesn't map to anything even with an href. - therefore, it no longer makes sense to try to determine role and evaluate, so it should be skipped. - accordingly, tests are deleted since we don't want to evaluate it. --- tests/role-supports-aria-props.js | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/tests/role-supports-aria-props.js b/tests/role-supports-aria-props.js index 1858b9cf..a7658712 100644 --- a/tests/role-supports-aria-props.js +++ b/tests/role-supports-aria-props.js @@ -75,27 +75,6 @@ ruleTester.run('role-supports-aria-props', rule, { {code: ''}, {code: ''}, - // LINK TESTS - implicit role is `link` - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - {code: ''}, - - // this will have global - {code: ''}, - // this will have role of `img` {code: 'foobar'}, @@ -338,6 +317,7 @@ ruleTester.run('role-supports-aria-props', rule, { {code: ''}, {code: '
'}, {code: '
'}, + {code: ''}, // link maps to nothing ], invalid: [ @@ -358,10 +338,6 @@ ruleTester.run('role-supports-aria-props', rule, { code: '', errors: [getErrorMessage('aria-checked', 'link')], }, - { - code: '', - errors: [getErrorMessage('aria-checked', 'link')], - }, { code: 'foobar', errors: [getErrorMessage('aria-checked', 'img')], @@ -482,10 +458,6 @@ ruleTester.run('role-supports-aria-props', rule, { code: '', errors: [getErrorMessage('aria-expanded', 'toolbar')], }, - { - code: '', - errors: [getErrorMessage('aria-invalid', 'link')], - }, { code: '', errors: [getErrorMessage('aria-invalid', 'link')], From d21a25e6a81d9e8903e394d595c6d7d5fe9c651d Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:46:35 -0400 Subject: [PATCH 05/19] body now maps to generic role - see https://www.w3.org/TR/html-aria/ and https://www.w3.org/TR/html-aam-1.0/ --- tests/role-supports-aria-props.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/role-supports-aria-props.js b/tests/role-supports-aria-props.js index a7658712..fd2bc2dc 100644 --- a/tests/role-supports-aria-props.js +++ b/tests/role-supports-aria-props.js @@ -372,7 +372,7 @@ ruleTester.run('role-supports-aria-props', rule, { }, { code: '', - errors: [getErrorMessage('aria-expanded', 'document')], + errors: [getErrorMessage('aria-expanded', 'generic')], }, { code: '
  • ', From 281fa951c006b915fca4c84be4ac8543dd3f1adb Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:21:53 -0400 Subject: [PATCH 06/19] `summary` does not map to anything anymore --- lib/rules/role-supports-aria-props.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/rules/role-supports-aria-props.js b/lib/rules/role-supports-aria-props.js index 370bb696..858c4bed 100644 --- a/lib/rules/role-supports-aria-props.js +++ b/lib/rules/role-supports-aria-props.js @@ -44,9 +44,7 @@ module.exports = { // - Get the element’s name const key = {name: getElementType(context, node)} // - Get the element’s disambiguating attributes - for (const prop of ['aria-expanded', 'type', 'size', 'role', 'href', 'multiple', 'scope']) { - // - Only provide `aria-expanded` when it’s required for disambiguation - if (prop === 'aria-expanded' && key.name !== 'summary') continue + for (const prop of ['type', 'size', 'role', 'href', 'multiple', 'scope']) { const value = getPropValue(getProp(node.attributes, prop)) if (value) { if (!('attributes' in key)) { From 33fe0b0db356303fbda489486e1946a767a8c7bf Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:54:43 -0400 Subject: [PATCH 07/19] Add aria-label and aria-labelledby and alt and name Add additional dis-ambiguating attributes. When `aria-label` or `aria-labelledby` is set at all, constraints should be set. --- lib/rules/role-supports-aria-props.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/rules/role-supports-aria-props.js b/lib/rules/role-supports-aria-props.js index 858c4bed..ab447e72 100644 --- a/lib/rules/role-supports-aria-props.js +++ b/lib/rules/role-supports-aria-props.js @@ -9,10 +9,6 @@ const elementRolesMap = new ObjectMap() for (const [key, value] of elementRoles.entries()) { // - Remove unused `constraints` key delete key.constraints - // - Remove `constraints` key within `attributes` - for (const attribute of key.attributes || []) { - delete attribute.constraints - } // - Remove empty `attributes` key if (!key.attributes || key.attributes?.length === 0) { delete key.attributes @@ -44,14 +40,31 @@ module.exports = { // - Get the element’s name const key = {name: getElementType(context, node)} // - Get the element’s disambiguating attributes - for (const prop of ['type', 'size', 'role', 'href', 'multiple', 'scope']) { + for (const prop of [ + 'aria-label', + 'aria-labelledby', + 'alt', + 'type', + 'size', + 'role', + 'href', + 'multiple', + 'scope', + 'name', + ]) { + if ((prop === 'aria-labelledby' || prop === 'aria-label') && !['section', 'aside', 'form'].includes(key.name)) + continue + if (prop === 'name' && key.name !== 'form') continue + const value = getPropValue(getProp(node.attributes, prop)) if (value) { if (!('attributes' in key)) { key.attributes = [] } - if (prop === 'href') { - key.attributes.push({name: prop}) + if (prop === 'href' || prop === 'aria-labelledby' || prop === 'aria-label') { + key.attributes.push({name: prop, constraints: ['set']}) + } else if (prop === 'alt' && value !== '') { + key.attributes.push({name: prop, constraints: ['set']}) } else { key.attributes.push({name: prop, value}) } From 985fa01bdba1ef27138ddd1f0790dec7ebdff63b Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:59:57 -0400 Subject: [PATCH 08/19] update tests to reflect truth --- tests/role-supports-aria-props.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/role-supports-aria-props.js b/tests/role-supports-aria-props.js index fd2bc2dc..d215eb02 100644 --- a/tests/role-supports-aria-props.js +++ b/tests/role-supports-aria-props.js @@ -348,7 +348,7 @@ ruleTester.run('role-supports-aria-props', rule, { }, { code: '