From 75c9d68ea4372ae54d973d7fb6fc3bf3c0b1d09a Mon Sep 17 00:00:00 2001 From: Billy Levin Date: Fri, 23 Aug 2024 08:51:14 +0100 Subject: [PATCH] [New] - `label-has-associated-control`: new error message Fixes #1005 by introducing a second error message, used when the label doesn't have accessible text. --- .../label-has-associated-control-test.js | 25 ++++---- src/rules/label-has-associated-control.js | 57 +++++++++++-------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/__tests__/src/rules/label-has-associated-control-test.js b/__tests__/src/rules/label-has-associated-control-test.js index 0bd14107..c765d971 100644 --- a/__tests__/src/rules/label-has-associated-control-test.js +++ b/__tests__/src/rules/label-has-associated-control-test.js @@ -26,6 +26,11 @@ const expectedError = { type: 'JSXOpeningElement', }; +const expectedErrorNoLabel = { + message: 'A form label must have accessible text.', + type: 'JSXOpeningElement', +}; + const componentsSettings = { 'jsx-a11y': { components: { @@ -132,12 +137,12 @@ const nestingInvalid = [ ]; const neverValid = [ - { code: '