djLint icon indicating copy to clipboard operation
djLint copied to clipboard

[FEATURE] Linter rule idea: `for` must match `id` in same file

Open silverwind opened this issue 1 year ago • 0 comments

  • [x] I've searched the issues
  • [x] I've read the docs

Feature Request

A new rule that each for attribute on <label> has a exactly one matching id in the same file would be nice.

Failure:

<label for="wine"></label>
<input id="cheese">
<label for="wine"></label>
<input id="cheese">
<input id="cheese">

Success:

<label for="cheese"></label>
<input id="cheese">

In case elements are spread across multiple files it would produce false-positives, but I think such cases would be rare enough to not present a major issue.

silverwind avatar Mar 15 '24 12:03 silverwind