Skip to content

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.

fix(detect): flag Framer Motion whileHover scale and lift in hover-scale (#222)

Papito0841ac0a5040d4c
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 0b34070..55109f6 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1310,7 +1310,7 @@ const rules = [
message: "Cards that grow on hover.",
fix: "Show hover with a quick color or surface change. Keep scale for a small press-down on buttons.",
find({ code }) {
- return [...matches(/\b(?:group-)?hover:(?:-translate-y-\d|scale-1(?:0[2-9]|[1-9]\d)\b|scale-\[(?:1\.(?:0[2-9]\d*|[1-9]\d*)|[2-9]\d*(?:\.\d+)?)\])|:hover\s*\{[^}]*transform:\s*(?:scale\(1\.(?:0[2-9]|[1-9])|[^;}]*?\btranslateY\(\s*-\s*(?:\d*\.)?\d+|[^;}]*?\btranslate(?:3d)?\(\s*(?:[^,;()]|\([^()]*\))+,\s*-\s*(?:\d*\.)?\d+)|:hover\s*\{[^}]*?(?<![\w-])scale\s*:\s*(?:1\.0[2-9]\d*|1\.[1-9]\d*)\b|:hover\s*\{[^}]*?(?<![\w-])translate\s*:\s*(?:[^\s;}()]|\([^()]*\))+\s+-\s*(?:\d*\.)?\d+/, code)].map((m) => m.index);
+ return [...matches(/\b(?:group-)?hover:(?:-translate-y-\d|scale-1(?:0[2-9]|[1-9]\d)\b|scale-\[(?:1\.(?:0[2-9]\d*|[1-9]\d*)|[2-9]\d*(?:\.\d+)?)\])|:hover\s*\{[^}]*transform:\s*(?:scale\(1\.(?:0[2-9]|[1-9])|[^;}]*?\btranslateY\(\s*-\s*(?:\d*\.)?\d+|[^;}]*?\btranslate(?:3d)?\(\s*(?:[^,;()]|\([^()]*\))+,\s*-\s*(?:\d*\.)?\d+)|:hover\s*\{[^}]*?(?<![\w-])scale\s*:\s*(?:1\.0[2-9]\d*|1\.[1-9]\d*)\b|:hover\s*\{[^}]*?(?<![\w-])translate\s*:\s*(?:[^\s;}()]|\([^()]*\))+\s+-\s*(?:\d*\.)?\d+|\bwhileHover=\{\s*\{[^}]*?\b(?:scale\s*:\s*(?:1\.(?:0[2-9]\d*|[1-9]\d*)|[2-9]\d*(?:\.\d+)?)|y\s*:\s*-\s*(?:\d*\.)?\d+)\b/, code)].map((m) => m.index);
},
},
{
diff --git a/test/detect.test.js b/test/detect.test.js
index 8ae1d42..52d4828 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1590,6 +1590,41 @@ test("hover-scale flags a standalone translate lift, not zero, downward, x-only,
assert.deepStrictEqual(rulesFor(".card { translate: 0 -4px; }\n"), []);
});
+test("hover-scale flags Framer Motion whileHover scale and lift (issue #196)", () => {
+ const rulesFor = (src, file = "Card.tsx") => scanSource(src, file).map((f) => f.rule);
+ // Repro: Card.tsx
+ const repro = [
+ 'import { motion } from "framer-motion";',
+ "",
+ "export function Card() {",
+ ' return <motion.div whileHover={{ scale: 1.05 }}>Pro plan</motion.div>;',
+ "}",
+ "",
+ "export function Tile() {",
+ ' return <motion.div whileHover={{ y: -4 }}>Starter plan</motion.div>;',
+ "}",
+ "",
+ ].join("\n");
+ const findings = scanSource(repro, "Card.tsx");
+ assert.deepStrictEqual(findings.map((f) => ({ rule: f.rule, line: f.line })), [
+ { rule: "hover-scale", line: 4 },
+ { rule: "hover-scale", line: 8 },
+ ]);
+
+ // scale 1.02 and above, and with other keys
+ assert.deepStrictEqual(rulesFor('<motion.div whileHover={{ scale: 1.02 }}>x</motion.div>\n'), ["hover-scale"]);
+ assert.deepStrictEqual(rulesFor('<motion.div whileHover={{ scale: 1.05, opacity: 1 }}>x</motion.div>\n'), ["hover-scale"]);
+ assert.deepStrictEqual(rulesFor('<motion.div whileHover={{ opacity: 1, scale: 1.05 }}>x</motion.div>\n'), ["hover-scale"]);
+ assert.deepStrictEqual(rulesFor('<motion.div whileHover={{ opacity: 1, y: -4 }}>x</motion.div>\n'), ["hover-scale"]);
+
+ // Quiet cases: shrinking, non-motion props, other properties
+ assert.deepStrictEqual(rulesFor('<motion.div whileHover={{ scale: 0.98 }}>x</motion.div>\n'), []);
+ assert.deepStrictEqual(rulesFor('<motion.div whileHover={{ opacity: 0.8 }}>x</motion.div>\n'), []);
+ assert.deepStrictEqual(rulesFor('<motion.div whileTap={{ scale: 1.05 }}>x</motion.div>\n'), []);
+ assert.deepStrictEqual(rulesFor('<motion.div whileHover={{ scale: 1.01 }}>x</motion.div>\n'), []);
+ assert.deepStrictEqual(rulesFor('<motion.div whileHover={{ y: 4 }}>x</motion.div>\n'), []);
+});
+
test("glow-shadow catches Android shadowColor on one line or with alpha", () => {
const oneLine = '<TextView android:shadowColor="#7C3AED" android:shadowRadius="20" />';
const multiLine = '<TextView\n android:shadowColor="#807C3AED"\n android:shadowRadius="20" />';