Excessibility.LiveViewRules (Excessibility v0.14.0)
View SourceLiveView-aware accessibility rules.
Runs a set of HTML-level checks that axe-core cannot perform because
they depend on Phoenix-specific attributes (phx-click, phx-submit,
phx-debounce, etc.). These rules complement axe-core rather than
replace it — snapshot tests run both axe-core and these rules.
On non-Phoenix HTML the rules are no-ops: if no phx-* attributes
exist, no findings are produced.
Usage
{:ok, html} = File.read("snapshot.html")
result = Excessibility.LiveViewRules.scan(html)
for finding <- result.findings do
IO.puts("[#{finding.severity}] #{finding.rule}: #{finding.message}")
endOptions
:disable— list of rule ids to skip (default[]):only— if given, run only these rule ids (overrides:disable)
Adding custom rules
Register application-level rule modules via config:
config :excessibility, custom_live_view_rules: [MyApp.Rules.CustomRule]See Excessibility.LiveViewRules.Rule for the behaviour.
Summary
Types
@type result() :: %{ findings: [Excessibility.LiveViewRules.Rule.finding()], rules_run: [atom()] }
The aggregate result of a LiveView rule scan.
Functions
@spec rules() :: [module()]
Returns all registered rule modules (built-in + custom via config).
Scan an HTML string and return findings from all enabled rules.
Returns %{findings: [...], rules_run: [rule_id, ...]}. On a parse
failure returns %{findings: [], rules_run: []}.
Like scan/2, but reads HTML from a file path.