core/utils/accessibility_audit library
Pure, source-text-scanning accessibility audit — no Flutter
dependency, so it (and tool/accessibility_audit_check.dart, which
runs it against this package's own widgets) works as a genuinely
headless dart run CI check, no device/engine needed.
Deliberately covers only what's checkable from source text alone:
reduced-motion coverage, tap-target semantics coverage, and RTL
directional-safety. Contrast and text-scale coverage are NOT static-
scannable — they need real rendered pixels/layout, already covered by
theme_contrast_validator.dart (FEAT-68) and the golden matrix runner
(test/support/golden_matrix.dart, FEAT-69) respectively. This is a
deliberate scope cut, not an oversight — see this file's task
(doc/task/done/FEAT-76-accessibility-audit-cli.md) for the reasoning.
Classes
- AuditBaseline
- A parsed baseline file — every AuditViolation this baseline suppresses is dropped from a scan's reported results, but never silently: AuditSuppression.reason stays readable in the baseline source file itself as the paper trail for "why this one's accepted".
- AuditRule
-
One heuristic: if triggerPattern matches a file's source, the file
is expected to also match requiredPattern somewhere — if it
doesn't, that's a violation.
nullrequiredPattern means any triggerPattern match is itself always a violation (no "opt out" companion pattern makes sense for that rule). - AuditSuppression
- One pre-approved exception — reason must be non-empty (enforced by AuditBaseline.fromJson, which silently drops any entry missing one rather than let a reason-less suppression through).
- AuditViolation
- One reported violation — file is whatever path the caller passed in (typically repo-relative), not validated against the filesystem by this pure function.
Enums
Properties
-
defaultAuditRules
→ List<
AuditRule> -
The 3 rules this audit actually runs — see this file's doc comment for
why there are only 3, not 6.
final
Functions
-
scanAccessibility(
{required Map< String, String> fileContents, List<AuditRule> rules = const [], AuditBaseline baseline = AuditBaseline.empty}) → List<AuditViolation> -
Scans
fileContents(path → source text) againstrules, dropping anythingbaselinesuppresses. A file present infileContentswith no violations contributes nothing — this function never reports "clean" files, only actual findings.