Skip to content

feat(rules): add a11y/reduced-motion rule #711 - #2050

Merged
nc9 merged 11 commits into
mainfrom
boat/reduced-motion-711
Nov 18, 2026
Merged

nc9 merged 11 commits into
mainfrom
boat/reduced-motion-711

Conversation

@nc9

@nc9 nc9 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Adds a11y/reduced-motion: motion on a page with no prefers-reduced-motion handling. Closes #711.

How it works

  • Page-scope rule. Motion signals: an infinite CSS animation (animation or -webkit-animation) in an inline style attribute, or in an inline <style> or read stylesheet rule whose selector matches an element on the page; scroll-behavior: smooth in a rule whose selector matches the page (html, :root, body and * always match); a <video> with both autoplay and loop; <marquee>; an auto-advancing carousel (data-autoplay with a value other than empty, false, 0 or off, or a library autoplay option); AOS, GSAP ScrollTrigger, Lottie, animate.css/WOW.js, parallax libs and Locomotive/Lenis, with library names matched only in the URL path of a script, stylesheet, preload or modulepreload link (never canonical, hreflang or other links).
  • Handling counts only for a real @media (prefers-reduced-motion ...) rule (inline or read stylesheet; comments do not count), a script that calls matchMedia with the query (inline or read), or a stylesheet whose media attribute carries the query (its motion is then gated). The words in body text do not count.
  • Warn when everything referenced was read; info with "partial check" when a referenced stylesheet or same-site script was not read.
  • When a linked stylesheet was not read (a third-party stylesheet, a fetch error, the 20-sheet limit, a file over 1 MB) and the rule would otherwise pass, it emits a declared skipped check reduced-motion-unverified, never the clean reduced-motion pass (which clears all 11 problem checks). Exception: a stylesheet from a known font-only host (FONT_ONLY_STYLESHEET_HOSTS: fonts.googleapis.com, fonts.bunny.net, use.typekit.net, p.typekit.net, api.fontshare.com) holds only @font-face rules and is not counted as unread. use.fontawesome.com is not on the list, because its CSS has animations.
  • One check name per motion source (reduced-motion-<source>), so the report groups it into one finding listing the pages.
  • Data gap: new site.stylesheetMotion summary (read, mentionsReducedMotion, hasInfiniteAnimation, hasSmoothScroll, infiniteAnimationSelectors and smoothScrollSelectors, each capped at 100 selectors of 200 chars) computed in the adapter from the existing bounded stylesheet fetch. Bodies are never kept.
  • CSS reading reuses parseRules/parseDeclarations from content/hidden-text.ts, capped at 512 KB and 5000 rules per file; inline CSS is parsed once per page; selector matching is capped at 200 querySelector calls per page.

Score and cache effect

  • The rule cache key is bumped to prc-9 (main was on prc-8), and keyed on the stylesheet motion summary, so the first audit after the upgrade runs page rules fresh.
  • Score: the engine golden's overall health goes from 56 to 57. Pages with no detected motion and no unread stylesheet gain a reduced-motion pass the day this ships; a page with no detected motion but an unread stylesheet gets a skipped reduced-motion-unverified check instead. Accessibility rule count 62 to 63.

Acceptance criteria (evidence in packages/rules/tests/reduced-motion-711.test.ts)

  • AOS fixture warns, names AOS: "AOS with no handling warns and names AOS"
  • inline infinite animation warns; reduce query clears: "inline infinite animation warns; a reduce query clears it"
  • video autoplay loop + handling in read first-party stylesheet: no finding
  • marquee / autoplay carousel warn: "marquee and autoplay carousel warn"
  • hover transitions only: no finding
  • unread stylesheet: info, message says partial; with no finding, a skipped reduced-motion-unverified check and no pass ("an unread stylesheet with no motion gives the unverified skipped check, no pass", "an unread stylesheet plus inline handling still gives no pass")
  • matchMedia in inline or fetched script counts: "matchMedia in a read script counts as handling", "a script needs matchMedia and the query; GSAP matchMedia counts; the query alone does not"
  • 20 template pages: one finding: "template pages share one check name"
  • bounded stylesheet reading: "hostile stylesheets stay within the budget"
  • docs page docs/rules/a11y/reduced-motion.mdx cites WCAG 2.3.3 and 2.2.2

Review fix round (failing first on e00ec80: 12 fail / 12 pass; after: 24 pass / 0 fail): unused .fa-spin rule not a finding, canonical /team/lottie-smith not a finding, play-once autoplay video and empty or false data-autoplay off, -webkit-animation detected, body text and CSS comments not handling.

Fix round 2 (failing first on a9e7ba8: 4 fail / 27 pass; after: 31 pass / 0 fail): a page with only a Google Fonts sheet and no motion passes; the same page with a used looping animation and no handling warns (not info); a cdn.shopify.com sheet stays reduced-motion-unverified; use.fontawesome.com stays unverified; an unused .scroll-smooth{scroll-behavior:smooth} is not a finding; html, :root, body and * smooth scrolling warn; a used .scroll-smooth warns (inline and in a read sheet).

Gates (head a6bd176, rebased onto main with sign-off)

  • bun run scripts/test-suites.ts --run rules (ci.yml step): 11297 pass, 25 todo, 0 fail
  • bun run scripts/test-suites.ts --run audit-engine (ci.yml step): 2241 pass, 3 skip, 0 fail
  • bun run test:engine (goldens): 269 pass, 1 skip, 0 fail (no regeneration needed)
  • bun run typecheck in packages/rules (src + tests) and packages/audit-engine: pass
  • bun run format:check and bun run lint: pass
  • make validate in docs/: pass

The squirrelscan agent skill does not need a change.

Basis for the font-host list: a local sample of 203 stored homepages from recent CLI audits, where 26.6% link a stylesheet from another host and fonts.googleapis.com is on 17.2% of all pages (about two thirds of the third-party cases; next were cdn.shopify.com 3.0%, cdnjs 1.5%, use.typekit.net 1.0%, fonts.bunny.net and api.fontshare.com 0.5% each).
Caveats: a small sample, homepages only, and only the sites we happened to audit, so the shares are indicative, not measured across the web.

@nc9
nc9 force-pushed the boat/reduced-motion-711 branch 7 times, most recently from e00ec80 to a9e7ba8 Compare November 17, 2026 17:55
@nc9
nc9 force-pushed the boat/reduced-motion-711 branch 3 times, most recently from ab98190 to 7b42c98 Compare November 17, 2026 22:01
nc9 added a commit that referenced this pull request Nov 17, 2026
…for self-starting motion; pin 2.3.3 in the a11y WCAG test #2050

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 marked this pull request as ready for review November 18, 2026 00:26
nc9 added 11 commits November 18, 2026 11:26
…ealth score 57, changelog #711

Signed-off-by: Nik Cubrilovic <[email protected]>
… link names and body text #711

An animation in a stylesheet counts only when its selector matches an element
on the page, library names are read only from script, stylesheet and preload
URL paths, a video needs autoplay and loop, an empty data-autoplay is off,
-webkit-animation is detected, and handling needs a real reduced-motion
@media rule or a matchMedia script. A page with an unread linked stylesheet
gets a skipped reduced-motion-unverified check instead of the clean pass.
The inline CSS is parsed once.

Signed-off-by: Nik Cubrilovic <[email protected]>
…l selectors in a11y/reduced-motion #711

Signed-off-by: Nik Cubrilovic <[email protected]>
…ced-motion pseudo stripping pub#2050

Signed-off-by: Nik Cubrilovic <[email protected]>
…for self-starting motion; pin 2.3.3 in the a11y WCAG test #2050

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the boat/reduced-motion-711 branch from 24842ee to 679c62f Compare November 18, 2026 00:27
@nc9
nc9 merged commit d3a18c9 into main Nov 18, 2026
16 checks passed
@nc9
nc9 deleted the boat/reduced-motion-711 branch November 18, 2026 00:41
nc9 added a commit that referenced this pull request Nov 18, 2026
…for self-starting motion; pin 2.3.3 in the a11y WCAG test #2050

Signed-off-by: Nik Cubrilovic <[email protected]>
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.

New rule: a11y/reduced-motion - motion with no prefers-reduced-motion handling

1 participant