Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 717 Bytes

File metadata and controls

34 lines (22 loc) · 717 Bytes

label-has-for

Enforce label tags have htmlFor attribute. Form controls using a label to identify them must have only one label that is programmatically associated with the control using: <label htmlFor={/* ID or name of control*/}>...</label>.

options

This rule takes no options

Passes

// passes when the label is hidden
<label aria-hidden="true"></label>

// passes when the label has a valid `htmlFor` prop
<label for="foo"></label>

// passes when it is not a label
<div></div>

Fails

// fails when a label is not hidden and has no `htmlFor`
<label></label>

See also