Skip to content

feat(rules): tag a11y rules with WCAG criterion and level, add --wcag-level (repo#3093) - #2024

Merged
nc9 merged 10 commits into
mainfrom
boat/wcag-tags-3093
Nov 17, 2026
Merged

nc9 merged 10 commits into
mainfrom
boat/wcag-tags-3093

Conversation

@nc9

@nc9 nc9 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Tags the a11y rules with WCAG success criteria as data and adds a level filter. Part of squirrelscan/repo#3086, implements squirrelscan/repo#3093.

What changed

  • packages/core-contracts/src/wcag.ts: one table of criteria (title, level, version); wcag("1.4.3") builds a rule's entry so a rule cannot state the wrong level. Unknown criteria throw at load.
  • Every a11y rule declares exactly one of meta.wcag (52 rules) or meta.wcagNone (10 rules), a one-sentence reason grounded in what its run() checks: accesskeys, input-types, duplicate-id-active, heading-order, landmark-one-main, landmark-regions, table-duplicate-name, image-redundant-alt, aria-text, paste-inputs (its run() covers any text field, not only authentication fields; narrowing it is a11y/paste-inputs: scope paste blocking to authentication fields so it can carry WCAG 3.3.8 #2106). a11y/duplicate-id-aria maps to 4.1.2. No rule's run() changes.
  • JSON schema 1.27 (1.25 meta.partialAudit is on main; 1.26 reserved for cacheFreshness, pub#2045): wcag and wcagLevel on a11y issues, top-level wcagByLevel, meta.partialAudit.wcagLevel. HTML (footer line, data-wcag-level, "Accessibility rules with findings, by WCAG level"), Markdown and text reports show criterion and level.
  • squirrel audit --wcag-level A|AA|AAA and [rules] wcag_level: Only run the accessibility rules mapped to a WCAG success criterion at or below this level: A, AA or AAA (AA keeps Level A and AA). These automated checks cover part of WCAG; passing them does not mean a site conforms. A multi-criterion rule runs if any criterion is at or below the level; a wcagNone rule does not run. Implemented as exact-id disable patterns for a11y rules only.
  • The filter is recorded: a narrowed run carries the partial-audit marker (buildPartialAudit) naming the level, in every format and the publish payload. --rule-include a11y/touch-targets --wcag-level AA is refused before the crawl.
  • Completions: bash lists --wcag-level once and completes A AA AAA, like zsh and fish.
  • Docs: docs/scripts/rule-wcag.ts generates the ## WCAG success criteria block on every a11y rule page (intro inside the markers; "No WCAG success criterion: " for wcagNone); --check and its new test run in make validate.
  • Corrected mapping: a11y/touch-targets cuts off at 44px, which is 2.5.5 (AAA), so it is tagged 2.5.5 AAA and its advice says the AA minimum (2.5.8) is 24px. It does not run under --wcag-level AA.
  • The schema bump is its own commit (chore(report): ... JSON schema 1.27), version lines only.

Acceptance criteria

  • All a11y rules declare criterion, level and version, or a reason for none, and a test fails otherwise: packages/rules/tests/a11y-wcag.test.ts ("every a11y rule declares exactly one of wcag or wcagNone", "a wcagNone reason is one non-empty sentence", "the rules that test no WCAG success criterion say why")
  • JSON and HTML report show criterion and level, group by level: packages/report/tests/json-wcag-3093.test.ts
  • CLI option and config key, help and completions: --wcag-level, [rules] wcag_level; apps/cli/tests/self/completion.test.ts ("audit --wcag-level completion")
  • A level-narrowed run is marked partial and names the level; the zero-rules case is refused: apps/cli/tests/controllers/partial-audit-1082.test.ts, apps/cli/tests/reports/output/console.test.ts, json-wcag-3093.test.ts
  • Rule docs generated from metadata: docs/scripts/rule-wcag.ts + docs/scripts/rule-wcag.test.ts, make validate passes
  • Wrong mappings corrected (touch-targets, duplicate-id-aria, the ten wcagNone rules)

Verification

  • bun test --timeout 30000, explicit files: packages/rules a11y-wcag, rule-verdict-scope, rule-check-declarations, docs-rule-pages: 393 pass. packages/report json-wcag-3093, json-pages-1260, robots-honoured-1782: 22 pass. apps/cli completion, partial-audit-1082, console, rule-filter: 181 pass; audit-include-pages-e2e, audit-unstored-pages-1396-e2e, reconstruct-page-rule-counts-1260: 15 pass; partial-audit-rebuild-1082, partial-audit-report-1082-e2e: 4 pass. docs scripts glossary, check-links, rule-wcag: 66 pass.
  • Failing first: with d231010's source and the new tests, a11y-wcag 4 fail, json-wcag-3093 3 fail, completion + console 3 fail, partial-audit-1082 fails to load (no zeroRulesError), rule-wcag.test 3 fail.
  • typecheck: apps/cli, packages/core-contracts, packages/report, packages/rules (src + tests), packages/config. apps/cli format:check and lint clean.
  • make validate in docs/: tangly all checks passed, links good, glossary good, rule-checks and rule-wcag --check clean, 66 tests pass.

No new rule, so no rule counts change. Agent skill: a private follow-up is filed, squirrelscan/repo#4835.

@nc9
nc9 force-pushed the boat/wcag-tags-3093 branch 5 times, most recently from d231010 to f553ccf Compare November 17, 2026 17:38
@nc9
nc9 force-pushed the boat/wcag-tags-3093 branch 2 times, most recently from a71fe26 to d1a8e41 Compare November 17, 2026 18:30
@nc9

nc9 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Merge approved on 2026-11-18. This PR is over the 40-file threshold, so the merge needed a maintainer's go.

Reviewed at d1a8e41d: a full review checked 25 of the criterion mappings against WCAG 2.2, the rules whose checks test no success criterion now say so with the reason, and every check is green. It conflicts with main on the schema version line now that 1.26 has landed, so it merges after a rebase that keeps 1.27 and is re-checked.

Follow-ups tracked separately: the cloud keeping the WCAG fields through publish, the API honouring the partial-audit marker, and the agent skill mentioning --wcag-level.

nik

nc9 added 10 commits November 18, 2026 07:38
…dd --wcag-level (repo#3093)

Signed-off-by: Nik Cubrilovic <[email protected]>
…chema 1.25, not a CLI version (repo#1082)

Signed-off-by: Nik Cubrilovic <[email protected]>
…ith the reason; duplicate-id-aria maps to 4.1.2 (repo#3093)

RuleMeta gains wcagNone, and every a11y rule declares exactly one of wcag or
wcagNone. accesskeys, input-types, duplicate-id-active, heading-order,
landmark-one-main, landmark-regions, table-duplicate-name, image-redundant-alt,
aria-text and paste-inputs move to wcagNone (paste-inputs narrowing is
#2106). --wcag-level runs only mapped rules, so it
leaves those out at every level. No rule's run() changes. The generated rule
pages show the reason, and the intro, now inside the markers, says the checks
do not prove conformance.

Signed-off-by: Nik Cubrilovic <[email protected]>
…the level; refuse an include the level empties (repo#3093)

buildPartialAudit records wcagLevel for a run narrowed by --wcag-level or
[rules] wcag_level, and every renderer names it (text, markdown, console,
json meta.partialAudit.wcagLevel, xml wcag-level). The zero-rules pre-check
sees the level's disables, so --rule-include a11y/touch-targets --wcag-level
AA is refused before the crawl. Wording: --wcag-level only runs the rules
mapped to a criterion at or below the level, and passing them does not mean
a site conforms. The HTML line counts accessibility rules with findings.
Bash completion lists --wcag-level once and completes A AA AAA.

Signed-off-by: Nik Cubrilovic <[email protected]>
…partialAudit on main, 1.26 reserved for cacheFreshness, pub#2045)

Signed-off-by: Nik Cubrilovic <[email protected]>
…G-level or rule-filtered run (repo#3093, repo#1082)

Signed-off-by: Nik Cubrilovic <[email protected]>
…rd: no auto-publish, skipped as rule-filter (repo#3093)

Signed-off-by: Nik Cubrilovic <[email protected]>
… WCAG 2.2 has no 4.1.1 (repo#3093)

Signed-off-by: Nik Cubrilovic <[email protected]>
… level, and is not auto-published (repo#3093)

Signed-off-by: Nik Cubrilovic <[email protected]>
…in in landmark-regions wcagNone #3093

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the boat/wcag-tags-3093 branch from c3de705 to 5ce4dac Compare November 17, 2026 20:38
@nc9
nc9 merged commit 8879f6d into main Nov 17, 2026
16 checks passed
@nc9
nc9 deleted the boat/wcag-tags-3093 branch November 17, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant