Skip to content

fix(rules): count label elements in form-field-multiple-labels, skip readable alt in image-redundant-alt - #1289

Closed
nc9 wants to merge 1 commit into
mainfrom
fix/a11y-label-alt-1249-1273
Closed

nc9 wants to merge 1 commit into
mainfrom
fix/a11y-label-alt-1249-1273

Conversation

@nc9

@nc9 nc9 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1249
Fixes #1273

What changed

  • a11y/form-field-multiple-labels: labels are collected as a set of label elements, as a browser's input.labels does. A <label for="a"> that wraps id="a" is one label. A wrapping label whose for names another control does not label this one, and a wrapping label labels only its first labelable control (HTML's labeled control rule). for ids are matched as strings, not spliced into a selector. Two real labels on one control still warn with an accurate count.
  • a11y/image-redundant-alt: the filename test now needs the alt to look like a raw filename or slug (a single token, or the decoded filename spelled exactly). alt="Google Partner Logo" on google-partner-logo.svg passes; alt="arrow-downwards" on arrow-downwards.svg still warns; the redundant-prefix, surrounding-text and figcaption checks are untouched. Percent-escapes in the filename are decoded before comparing.
  • No rule added or removed, rule count unchanged, no new option, no perRuleTally change.

Tests (failing first)

  • packages/rules/tests/form-field-multiple-labels-1249.test.ts (6 of its 10 cases failed before the fix) and packages/rules/tests/image-redundant-alt-1273.test.ts (2 failed before).
  • Passing: both new files, rule-verdict-scope, template-verdict-inputs, template-verdict-page-independence, docs-rule-pages, docs-category-table, streaming-rules-canonical-golden (no pin moved), make validate in docs/.
  • Not run: the full scripts/test-suites.ts --run rules suite and an end-to-end squirrel audit of the issue pages; no real-site smoke test.
  • Local Bun is not the pinned 1.4.4; I did not reformat the two existing rule files (they do not match the pinned formatter), new test files are formatted.

Docs: docs/rules/a11y/form-field-multiple-labels.mdx, docs/rules/a11y/image-redundant-alt.mdx. Skill: none.

Note (review)

image-redundant-alt: an alt written as a spaced raw filename that is not the decoded filename exactly (for example alt="IMG 1234" on IMG_1234.jpg) no longer warns, because whitespace now marks a readable description. Accepted trade-off.

…readable alt in image-redundant-alt #1249 #1273

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9 nc9 mentioned this pull request Oct 30, 2026
@nc9

nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.142 via the stacked release PR #1331: 1ea94aae and the commits after it on main (rebase-merged, so this PR shows as closed rather than merged).

@nc9 nc9 closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant