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 hover-scale with Tailwind arbitrary scale values (#53)

Nguyễn Tuấn Anhcab06322a83e
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 79eaa0f..3aa833c 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -647,7 +647,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|:hover\s*\{[^}]*transform:\s*scale\(1\.(?:0[2-9]|[1-9])/, 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])/, code)].map((m) => m.index);
},
},
{
diff --git a/test/detect.test.js b/test/detect.test.js
index b0fb548..5f77db2 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -362,3 +362,16 @@ test("glow-shadow catches Tailwind colored and arbitrary shadows while ignoring
].join("\n");
assert.deepStrictEqual(scanSource(neutral, "a.tsx"), []);
});
+
+test("hover-scale flags Tailwind arbitrary scale values of 1.02 and above", () => {
+ const rulesFor = (src) => scanSource(src, "a.tsx").map((f) => f.rule);
+ // The issue's example line, plus the group- prefix variant.
+ assert.deepStrictEqual(rulesFor('<div className="hover:scale-[1.03]">x</div>\n'), ["hover-scale"]);
+ assert.deepStrictEqual(rulesFor('<div className="group-hover:scale-[1.02]">x</div>\n'), ["hover-scale"]);
+ assert.deepStrictEqual(rulesFor('<div className="hover:scale-[1.25]">x</div>\n'), ["hover-scale"]);
+ // At or below 1.01 the grow is too small to flag.
+ assert.deepStrictEqual(rulesFor('<div className="hover:scale-[1.01]">x</div>\n'), []);
+ assert.deepStrictEqual(rulesFor('<div className="hover:scale-[0.98]">x</div>\n'), []);
+ // The named steps still work.
+ assert.deepStrictEqual(rulesFor('<div className="hover:scale-105">x</div>\n'), ["hover-scale"]);
+});