Your app looks AI-generated. Vincent Van Gogh noticed. An agent skill that finds and fixes AI-looking UI and UX in mobile apps, web apps, and websites.
JavaScript accessibilityagent-skillsagent-skills-toolsagentsagentskillsai-slopclaudeclaude-codeclaude-skillsexpoflutterfrontendionicjetpack-composemobilereact-nativeswiftuiuiuxvibe-coding
Add a reduced-motion rule for animations with no prefers-reduced-motion fallback (#104)
Nguyễn Tuấn Anhf46a561d5c43
diff --git a/skills/unslop-anything/reference/web.md b/skills/unslop-anything/reference/web.mdindex 51def1b..d4a3f3d 100644--- a/skills/unslop-anything/reference/web.md+++ b/skills/unslop-anything/reference/web.md@@ -23,7 +23,7 @@ These break the web for real people. They are Critical or Noticeable, whatever t- **Text alternatives.** Every content image has alt text; decoration has `alt=""` [`img-no-alt`].- **URLs mean something.** The back button returns to the previous view. Filters, tabs, search, and pagination that someone would share live in the URL. Opening in a new tab works.- **Contrast** 4.5:1 for body text and 3:1 for large text and meaningful icons, in light and dark.-- **Reduced motion.** Every animation has a `prefers-reduced-motion: reduce` fallback. Content is visible without it.+- **Reduced motion.** Every animation has a `prefers-reduced-motion: reduce` fallback. Content is visible without it [`reduced-motion`].- **No horizontal scroll** at 375 wide, and the layout holds at 1920: the content width is capped and centered, the gutters grow.- **Forms** have labels (not placeholders as labels), the right `type` and `autocomplete`, errors next to the field in words, and the entered data kept after an error.- **Nothing invented.** No customer counts, logo walls, testimonials, ratings, or case studies the user did not supply [`unverified-claim`, `invented-stat`].diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex 1a37d67..4610529 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -808,6 +808,35 @@ const rules = [return hits;},},+ {+ id: "reduced-motion",+ family: "motion",+ severity: "minor",+ stacks: ["js", "web", "css"],+ message: "Animation with no prefers-reduced-motion fallback (first use in this file).",+ fix: "Add a @media (prefers-reduced-motion: reduce) fallback that stops the animation, or guard the class with a motion-reduce: variant.",+ find({ code }) {+ // Reported once per file, like transition-all: a missing fallback+ // is usually a habit, not a one-off. A fallback anywhere in the+ // file covers it, so the check is file-wide.+ if (/prefers-reduced-motion/.test(code)) return [];+ const hits = [];+ // Plain CSS: the first @keyframes block or animation: declaration.+ const css = matches(/@keyframes\b|\banimation\s*:\s*["'`]?(?!none\b)[^;"'`\n]*?\d*\.?\d+m?s\b/, code).next();+ if (!css.done) hits.push(css.value.index);+ // Tailwind: an animate-* class with no motion-safe: or+ // motion-reduce: variant in the same class string. animate-spin is+ // a spinner and animate-none turns motion off, so neither counts;+ // skeleton pulses are loading states, like decorative-pulse.+ for (const m of matches(/["'`][^"'`\n]*\banimate-(?:(?!spin\b)(?!none\b)[\w-]+|\[[^\s"'`\]]+\])[^"'`\n]*["'`]/, code)) {+ if (/\bmotion-(?:safe|reduce):/.test(m[0])) continue;+ if (/\banimate-pulse\b/.test(m[0]) && /\bbg-(?:gray|slate|zinc|neutral|stone|muted)\b|skeleton/i.test(m[0])) continue;+ hits.push(m.index);+ break;+ }+ return hits.length ? [Math.min(...hits)] : [];+ },+ },{id: "unverified-claim",family: "truthfulness",diff --git a/test/detect.test.js b/test/detect.test.jsindex b69279a..a5ade65 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -325,6 +325,35 @@ test("transition-all stops at the quote that ends a CSS-in-JS value", () => {assert.deepStrictEqual(scanSource(singleQuoted, "a.tsx").map((f) => f.rule), ["transition-all"]);});+test("reduced-motion flags animations with no prefers-reduced-motion fallback (issue #72)", () => {+ // The issue's exact repro: a @keyframes animation with no fallback.+ const repro = ".badge { animation: bounce 1s infinite; }\n@keyframes bounce { 50% { transform: translateY(-4px); } }\n";+ assert.deepStrictEqual(scanSource(repro, "a.css").map((f) => f.rule), ["reduced-motion"]);+ // Reported once per file: the @keyframes block is not a second finding.+ assert.strictEqual(scanSource(repro, "a.css").length, 1);+ // A @keyframes block on its own counts too.+ assert.deepStrictEqual(scanSource("@keyframes fade { from { opacity: 0; } }\n", "a.css").map((f) => f.rule), ["reduced-motion"]);+ // A prefers-reduced-motion fallback anywhere in the file silences it.+ const guarded = "@media (prefers-reduced-motion: reduce) { .badge { animation: none; } }\n" + repro;+ assert.deepStrictEqual(scanSource(guarded, "a.css"), []);+ // Tailwind: an unguarded animate-* class counts.+ assert.deepStrictEqual(scanSource('<div className="animate-bounce" />', "a.tsx").map((f) => f.rule), ["reduced-motion"]);+ assert.deepStrictEqual(scanSource('<div className="animate-ping" />', "a.tsx").map((f) => f.rule), ["decorative-pulse", "reduced-motion"]);+ // A motion-reduce: variant on the same element silences it.+ assert.deepStrictEqual(scanSource('<div className="motion-reduce:animate-none animate-bounce" />', "a.tsx"), []);+ // animate-spin is a spinner, and skeleton pulses are loading states.+ assert.deepStrictEqual(scanSource('<div className="animate-spin" />', "a.tsx"), []);+ assert.deepStrictEqual(scanSource('<div className="h-4 w-32 animate-pulse rounded bg-zinc-200" />', "a.tsx"), []);+ // A non-skeleton pulse still counts (and still trips decorative-pulse).+ assert.deepStrictEqual(scanSource('<span className="animate-pulse bg-emerald-400" />', "a.tsx").map((f) => f.rule), ["decorative-pulse", "reduced-motion"]);+ // A plain transition is not an animation.+ assert.deepStrictEqual(scanSource(".b { transition: color .2s; }\n", "a.css"), []);+ assert.deepStrictEqual(scanSource(".modal { animation: none; }\n", "a.css"), []);+ assert.deepStrictEqual(scanSource('<Stack.Screen options={{ animation: "slide_from_right" }} />\n', "a.tsx"), []);+ assert.deepStrictEqual(scanSource("const options = { animation: false };\n", "a.ts"), []);+ assert.deepStrictEqual(scanSource('const Badge = styled.span`animation: ${bounce} 1s infinite;`;\n', "a.tsx").map((f) => f.rule), ["reduced-motion"]);+});+test("slop-gradient reads Android #AARRGGBB colors", () => {const src = '<gradient android:startColor="#FF7C3AED" android:endColor="#FFEC4899"/>\n';assert.deepStrictEqual(scanSource(src, "bg.xml").map((f) => f.rule), ["slop-gradient"]);@@ -549,7 +578,7 @@ test("web slop is caught", () => {const found = new Set(scan([path.join(fixtures, "slop", "web")]).findings.map((f) => f.rule));for (const id of ["slop-gradient", "gradient-text", "tracked-caps-label", "unverified-claim", "img-no-alt", "decorative-pulse",- "clickable-div", "transition-all", "hover-scale", "icon-tile", "focus-removed", "zoom-disabled",+ "clickable-div", "transition-all", "hover-scale", "icon-tile", "focus-removed", "zoom-disabled", "reduced-motion",]) assert.ok(found.has(id), `missing ${id}`);});diff --git a/test/fixtures/slop/web/styles.css b/test/fixtures/slop/web/styles.cssindex 3c9025b..01ed3d3 100644--- a/test/fixtures/slop/web/styles.css+++ b/test/fixtures/slop/web/styles.css@@ -19,3 +19,13 @@ button {background-clip: text;color: transparent;}++.badge {+ animation: bounce 1s infinite;+}++@keyframes bounce {+ 50% {+ transform: translateY(-4px);+ }+}