Sort axe report violations by severity, then standard#14676
Open
cwickham wants to merge 3 commits into
Open
Conversation
cwickham
added a commit
that referenced
this pull request
Jul 13, 2026
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Member
Author
|
Added a Playwright regression test ( |
The axe document reporter previously listed violations in axe-core's own order. Sort them most-important-first: by impact (critical, serious, moderate, minor, then null), then by conformance standard (WCAG A, AA, AAA, Best Practice, obsolete, untagged), then by rule id for deterministic output. Sorting happens in createReportElement, so the fixed overlay, revealjs report slide, dashboard offcanvas, and dashboard rescans all inherit it. The reporter sorts a copy, so the json reporter keeps emitting axe's raw result untouched. The rank helpers are exported for unit tests (and for reuse by the upcoming project scanner), alongside a parseConformanceTags helper now shared with axeConformanceLevel.
The fixture triggers image-alt (critical), color-contrast (serious), and heading-order (moderate); axe-core emits these roughly alphabetically by rule id, which is not severity order, so the test fails if the report stops sorting. Standard tie-breaks within one impact level are covered by the unit tests instead — triggering two same-impact rules with different standards is fragile against axe-core upgrades.
e8c9b3a to
c6c63bd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Stacked on #14677 — do not merge before it. The base is
axe/vendor-axe-core; when #14677 merges, GitHub retargets this PR tomainand it merges cleanly (the changelog conflict between the two is already resolved here).Description
The
axedocument reporter currently lists violations in axe-core's own order. This PR sorts them most-important-first, matching axe DevTools' impact-first convention:The sort happens in
createReportElement, so all three report containers (fixed overlay, revealjs report slide, dashboard offcanvas) and the dashboard rescan path inherit it. The reporter sorts a copy of the violations array, sooutput: jsonkeeps emitting axe's raw result untouched, andconsoleoutput is unchanged.The rank helpers (
impactRank,standardRank,compareViolations) are exported for unit testing, following theaxeConformanceLevelpattern, and share a newparseConformanceTagshelper withaxeConformanceLevelrather than duplicating the tag regexes. The exported helpers are also intended for reuse by the upcoming project-level accessibility scanner.Part of the axe accessibility QoL series.
Checklist
I have (if applicable):
Notes: no GitHub issue exists for this change (QoL improvement agreed in the axe PR series plan); no user-facing option is added, so no docs PR is needed. New unit tests in
tests/unit/axe-sort.test.ts(8 tests) pass, as do the existingtests/unit/axe-conformance.test.tstests (9) covering the shared-parser refactor. The existing Playwright axe assertions usetoContainTextand are order-insensitive, so they pass unchanged.AI-assisted PR