eslint-plugin-jsx-a11y: `label-has-for` false positive when using `allowChildren`
When using this rule:
"jsx-a11y/label-has-for": [2, {
"required": {"every": ["nesting"]},
"allowChildren": true
}]
This code passes the linter check:
<label>Firstname</label>
<input type="text" name="firstname" />
Currently it passes due to case 'Literal': return Boolean(child.value); in hasAccessibleChild I think.
Or am I missing something?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (10 by maintainers)
Hey y’all, sorry for the inconvenience. I’ll check this first thing tomorrow morning. I suspect it is what @amannn pointed out, in hasAccessibleChild. When I initially wrote #259 I didn’t use it and checked specifically for a JSXExpressionContainer. That change might fix it, and I’ll add additional test cases to check for that, too.
@ljharb understood, I’ll make it happen and add the test cases.
@mjaltamirano agreed- that’s my bad for pointing you in this direction. we should be explicitly checking for a child element that’s not
Literal. sorry about that 😞 and thanks for fixing!I agree with point number 1 😃 the choice of all 4 options (perhaps with better names: [
id,nesting,id-and-nesting,id-or-nesting]?) would suffice for me (provided that theallowChildrenoption could be disabled, whatever that means for the new rule’s configuration)@ljharb Aha, I see what you mean. I’d like to push back a little:
everymeans nothing unless bothidandnestingare also specified. The interdependence is confusing.Yep, that’s correct.