-
-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form label must have associated control on compliant markup #302
Comments
Nevermind I needed to change the config from every to some
|
Could you elaborate on why it needs to be some? |
@captDaylight the default is "every" - you should both for-id-link and label-wrap your inputs. "some" means it will pass if you do either one of those. |
@ljharb hey thanks for the quick response, though I don't follow. I have a label and and input as at the top of the issue, htmlFor in label and id in input and it's throwing this error. What do you mean by for-id-link and label-wrap? |
@captDaylight i mean that a) the label's "for" matches the input's "id", and also b) the input must be inside the label. |
GOTCHA, ok, that makes sense. Thanks for the time! |
Just to help others that may find there way here, I simply did not realize that for my babel and jsx-a11y to work correctly together, I needed to use <label htmlFor... rather than just <label for... The following format passed all the linter rules. This did not require me to make the adjustment to my config / eslintrc rules. |
Could you please tell me what is config, where it is to change every to some? |
@skirankumar7
As you can see, I had to add the new stuff under "Rules" for the two rules that I was getting errors from. |
Quiet an uncommon eslint rule about <form /> format that complained after being satisfied. See: evcohen/eslint-plugin-jsx-a11y#302 Refs #316
Quiet an uncommon eslint rule about <form /> format that complained after being satisfied. See: evcohen/eslint-plugin-jsx-a11y#302 Refs #316
Quiet an uncommon eslint rule about <form /> format that complained after being satisfied. See: evcohen/eslint-plugin-jsx-a11y#302 Refs #316
Restart your local server and its works fine |
Eslint does not recognise linking label with control when the control is outside the label element. Fix found here: jsx-eslint/eslint-plugin-jsx-a11y#302 (comment)
Eslint does not recognise linking label with control when the control is outside the label element. Fix found here: jsx-eslint/eslint-plugin-jsx-a11y#302 (comment)
as per jsx-eslint/eslint-plugin-jsx-a11y#302 requiring a label to be both nested and having a forHtml is unnecessary
Available values for {
// ...
rules: {
'jsx-a11y/label-has-associated-control': [
2,
{
assert: 'either', // either check for `htmlFor` or `nesting`
},
],
}
} |
This example markup is compliant.
Why is linting failing with..
The text was updated successfully, but these errors were encountered: