Open tomdglenn91 opened 11 months ago
I would agree that has an htmlFor attribute and that the label tag has text content.
matches the reality and not your expectation.
However, I would expect that 2 should also be checking that the htmlFor
value matches the label's id
value.
That seems like a useful option to add.
Apologies if I've misunderstood the rule or configured this wrong.
I'm noticing in our code base that labels are often misconfigured, using
name
as the matcher, notid
, which isn't a valid pairing.I want to ensure that every (custom) input element has an associated label, and it's configured correctly. So the following works out the box:
Given the following configuration:
I expect this to fail, as no HtmlFor, which it fails.
I expect this to fail, as the htmlFor doesn't link to anything, but it doesn't fail. This is the scenario i see in our code base a lot that i want to protect against.
Then expect this to pass
Given that:
I feel like my expected behaviour is not the reality, but I wasn't quite sure.
Should my expectation work, or am I just misunderstanding the library/rule? Thanks.