From 662c6db26c7ba52178fc9ac79e960eba3b51f7d3 Mon Sep 17 00:00:00 2001 From: jkodu Date: Wed, 7 Nov 2018 15:33:22 +0000 Subject: [PATCH 1/5] fix: make multiple-label a best-practice rule --- doc/rule-descriptions.md | 3 ++- lib/rules/label.json | 1 - lib/rules/multiple-label.json | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 lib/rules/multiple-label.json diff --git a/doc/rule-descriptions.md b/doc/rule-descriptions.md index 25aa0af0f3..0aea63e85d 100644 --- a/doc/rule-descriptions.md +++ b/doc/rule-descriptions.md @@ -40,7 +40,7 @@ | image-redundant-alt | Ensure button and link text is not repeated as image alternative | Minor | cat.text-alternatives, best-practice | true | | input-image-alt | Ensures <input type="image"> elements have alternate text | Critical | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | true | | label-title-only | Ensures that every form element is not solely labeled using the title or aria-describedby attributes | Serious | cat.forms, best-practice | true | -| label | Ensures every form element has a label | Minor, Serious, Critical | cat.forms, wcag2a, wcag332, wcag131, section508, section508.22.n | true | +| label | Ensures every form element has a label | Minor, Critical | cat.forms, wcag2a, wcag332, wcag131, section508, section508.22.n | true | | landmark-banner-is-top-level | Ensures the banner landmark is at top level | Moderate | cat.semantics, best-practice | true | | landmark-contentinfo-is-top-level | Ensures the contentinfo landmark is at top level | Moderate | cat.semantics, best-practice | true | | landmark-main-is-top-level | Ensures the main landmark is at top level | Moderate | cat.semantics, best-practice | true | @@ -56,6 +56,7 @@ | meta-refresh | Ensures <meta http-equiv="refresh"> is not used | Critical | cat.time, wcag2a, wcag2aaa, wcag221, wcag224, wcag325 | true | | meta-viewport-large | Ensures <meta name="viewport"> can scale a significant amount | Minor | cat.sensory-and-visual-cues, best-practice | true | | meta-viewport | Ensures <meta name="viewport"> does not disable text scaling and zooming | Critical | cat.sensory-and-visual-cues, wcag2aa, wcag144 | true | +| multiple-label | Ensures form element does not have multiple label elements | Serious | best-practice, cat.forms, wcag2a, wcag332 | true | | object-alt | Ensures <object> elements have alternate text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | true | | p-as-heading | Ensure p elements are not used to style headings | Serious | cat.semantics, wcag2a, wcag131, experimental | true | | page-has-heading-one | Ensure that the page, or at least one of its frames contains a level-one heading | Moderate | cat.semantics, best-practice | true | diff --git a/lib/rules/label.json b/lib/rules/label.json index af1747f790..2dd754506b 100644 --- a/lib/rules/label.json +++ b/lib/rules/label.json @@ -24,7 +24,6 @@ ], "none": [ "help-same-as-label", - "multiple-label", "hidden-explicit-label" ] } diff --git a/lib/rules/multiple-label.json b/lib/rules/multiple-label.json new file mode 100644 index 0000000000..98466f78ed --- /dev/null +++ b/lib/rules/multiple-label.json @@ -0,0 +1,20 @@ +{ + "id": "multiple-label", + "selector": "input, select, textarea", + "matches": "label-matches.js", + "tags": [ + "best-practice", + "cat.forms", + "wcag2a", + "wcag332" + ], + "metadata": { + "description": "Ensures form element does not have multiple label elements", + "help": "Form element must not have multiple associated label elements" + }, + "all": [], + "any": [], + "none": [ + "multiple-label" + ] +} From e51025d2ce59b67330f50737e8a86e24345ee1fe Mon Sep 17 00:00:00 2001 From: jkodu Date: Wed, 7 Nov 2018 15:46:38 +0000 Subject: [PATCH 2/5] test: add integration tests for multiple-label rule --- test/integration/rules/label/label.html | 3 +-- test/integration/rules/label/label.json | 1 - .../rules/multiple-label/multiple-label.html | 16 ++++++++++++++++ .../rules/multiple-label/multiple-label.json | 13 +++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 test/integration/rules/multiple-label/multiple-label.html create mode 100644 test/integration/rules/multiple-label/multiple-label.json diff --git a/test/integration/rules/label/label.html b/test/integration/rules/label/label.html index 72cdda7ab9..6881ba4d43 100644 --- a/test/integration/rules/label/label.html +++ b/test/integration/rules/label/label.html @@ -37,7 +37,6 @@ -
- \ No newline at end of file + diff --git a/test/integration/rules/label/label.json b/test/integration/rules/label/label.json index 78c1067532..2d38b809f8 100644 --- a/test/integration/rules/label/label.json +++ b/test/integration/rules/label/label.json @@ -14,7 +14,6 @@ ["#fail10"], ["#fail11"], ["#fail22"], - ["#fail23"], ["#fail24"], ["#fail25"], ["#fail26"] diff --git a/test/integration/rules/multiple-label/multiple-label.html b/test/integration/rules/multiple-label/multiple-label.html new file mode 100644 index 0000000000..54582d5980 --- /dev/null +++ b/test/integration/rules/multiple-label/multiple-label.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/test/integration/rules/multiple-label/multiple-label.json b/test/integration/rules/multiple-label/multiple-label.json new file mode 100644 index 0000000000..9e66097df1 --- /dev/null +++ b/test/integration/rules/multiple-label/multiple-label.json @@ -0,0 +1,13 @@ +{ + "description": "multiple label test", + "rule": "multiple-label", + "violations": [ + ["#fail1"], + ["#fail2"], + ["#fail3"] + ], + "passes": [ + ["#pass1"], + ["#pass2"] + ] +} From 26362632b03b2eb9249f0dae31c3e0a773a125c9 Mon Sep 17 00:00:00 2001 From: jkodu Date: Thu, 8 Nov 2018 15:04:29 +0000 Subject: [PATCH 3/5] fix: update rule name and add integration tests --- doc/rule-descriptions.md | 2 +- lib/checks/label/multiple-label.json | 2 +- ...l.json => form-field-multiple-labels.json} | 2 +- .../rules/multiple-label/multiple-label.html | 72 ++++++++++++++++++- .../rules/multiple-label/multiple-label.json | 17 +++-- 5 files changed, 87 insertions(+), 8 deletions(-) rename lib/rules/{multiple-label.json => form-field-multiple-labels.json} (91%) diff --git a/doc/rule-descriptions.md b/doc/rule-descriptions.md index 0aea63e85d..ac9e71694e 100644 --- a/doc/rule-descriptions.md +++ b/doc/rule-descriptions.md @@ -28,6 +28,7 @@ | duplicate-id | Ensures every id attribute value is unique | Minor | cat.parsing, wcag2a, wcag411 | true | | empty-heading | Ensures headings have discernible text | Minor | cat.name-role-value, best-practice | true | | focus-order-semantics | Ensures elements in the focus order have an appropriate role | Minor | cat.keyboard, best-practice, experimental | true | +| form-field-multiple-labels | Ensures form element does not have multiple label elements | Moderate | best-practice, cat.forms, wcag2a, wcag332 | true | | frame-tested | Ensures <iframe> and <frame> elements contain the axe-core script | Critical | cat.structure, review-item | true | | frame-title-unique | Ensures <iframe> and <frame> elements contain a unique title attribute | Serious | cat.text-alternatives, best-practice | true | | frame-title | Ensures <iframe> and <frame> elements contain a non-empty title attribute | Serious | cat.text-alternatives, wcag2a, wcag241, wcag412, section508, section508.22.i | true | @@ -56,7 +57,6 @@ | meta-refresh | Ensures <meta http-equiv="refresh"> is not used | Critical | cat.time, wcag2a, wcag2aaa, wcag221, wcag224, wcag325 | true | | meta-viewport-large | Ensures <meta name="viewport"> can scale a significant amount | Minor | cat.sensory-and-visual-cues, best-practice | true | | meta-viewport | Ensures <meta name="viewport"> does not disable text scaling and zooming | Critical | cat.sensory-and-visual-cues, wcag2aa, wcag144 | true | -| multiple-label | Ensures form element does not have multiple label elements | Serious | best-practice, cat.forms, wcag2a, wcag332 | true | | object-alt | Ensures <object> elements have alternate text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | true | | p-as-heading | Ensure p elements are not used to style headings | Serious | cat.semantics, wcag2a, wcag131, experimental | true | | page-has-heading-one | Ensure that the page, or at least one of its frames contains a level-one heading | Moderate | cat.semantics, best-practice | true | diff --git a/lib/checks/label/multiple-label.json b/lib/checks/label/multiple-label.json index 9ec5f3c07f..508767e22b 100644 --- a/lib/checks/label/multiple-label.json +++ b/lib/checks/label/multiple-label.json @@ -2,7 +2,7 @@ "id": "multiple-label", "evaluate": "multiple-label.js", "metadata": { - "impact": "serious", + "impact": "moderate", "messages": { "pass": "Form element does not have multiple