require input elements to have a label (input-missing-label)

Labels are associated with the input element and is required for a17y.

Rule details

Examples of incorrect code for this rule:

<!-- no label element at all -->
<div>
    <strong>My field</strong>
    <input type="text">
</div>

<!-- unassociated label -->
<div>
    <label>My field</label>
    <input type="text">
</div>
4:6 - Input element does not have a label
10:6 - Input element does not have a label

Examples of correct code for this rule:

<!-- label with descendant -->
<div>
    <label>My field <input type="text"></label>
</div>

<!-- associated label -->
<div>
    <label for="my-field">My field</label>
    <input id="my-field" type="text">
</div>