react-a11y icon indicating copy to clipboard operation
react-a11y copied to clipboard

jsx-a11y/label-has-for never correct

Open jrhalchak opened this issue 8 years ago • 1 comments

I have recently upgraded our eslint and airbnb config amonst other things. I keep getting the lint error error Form label must have associated control jsx-a11y/label-has-for

My code looks like this, but I also get the error when using just a string (instead of inputID).

<input
    type="text"
    id={inputID}
    className="form-control u__hidden-sm-down"
    value={inputValue}
    onChange={this.handleInputChange}
    onKeyUp={this.handleKeyRelease}
/>
<label
    htmlFor={inputID}
    className={formStyles.someRandomClass}
>
    Search...
</label>

Am I doing something stylistically incorrectly here? I have a few examples of this happening in our application.

Order doesn't seem to matter.

jrhalchak avatar Dec 12 '17 14:12 jrhalchak

If you're receiving this error during linting versus being logged to the console during runtime then that is an issue with the eslint-plugin-jsx-a11y plugin and you can file it here: https://github.com/evcohen/eslint-plugin-jsx-a11y

Our libraries are similar and complimentary but are distinctly separate.

erin-doyle avatar Dec 15 '17 23:12 erin-doyle