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 chained scale() and scale3d() in hover-scale (#233)

Papito084a44a3f8c9927
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 55109f6..9080a5f 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+|\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);
+ 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*[^;}]*?\b(?:scale(?:3d)?\(\s*(?:1\.(?:0[2-9]\d*|[1-9]\d*)|[2-9]\d*(?:\.\d+)?)\b|translateY\(\s*-\s*(?:\d*\.)?\d+|translate(?: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 52d4828..bcec4a2 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1573,6 +1573,19 @@ test("hover-scale flags translate() and translate3d() lifts, not zero, downward,
assert.deepStrictEqual(rulesFor(".card { transform: translate(0, -6px); }\n"), []);
});
+test("hover-scale flags scale() after another transform function and scale3d() (issue #232)", () => {
+ const rulesFor = (src) => scanSource(src, "a.css", { kind: "web" }).map((f) => f.rule);
+ // Issue #232 repro: chained scale and scale3d in two hover blocks
+ const repro = ".card:hover {\n transform: rotate(-1deg) scale(1.05);\n}\n.tile:hover {\n transform: scale3d(1.05, 1.05, 1);\n}\n";
+ assert.deepStrictEqual(scanSource(repro, "card.css", { kind: "web" }).map((f) => [f.rule, f.line]), [["hover-scale", 1], ["hover-scale", 4]]);
+ assert.deepStrictEqual(rulesFor(".card:hover { transform: rotate(-1deg) scale(1.05); }\n"), ["hover-scale"]);
+ assert.deepStrictEqual(rulesFor(".tile:hover { transform: scale3d(1.05, 1.05, 1); }\n"), ["hover-scale"]);
+ assert.deepStrictEqual(rulesFor(".card:hover { transform: rotate(2deg) scale(0.98); }\n"), []);
+ assert.deepStrictEqual(rulesFor(".card:hover { transform: translateX(2px) scale(1.01); }\n"), []);
+ assert.deepStrictEqual(rulesFor(".card:hover { transform: scale3d(1, 1, 1); }\n"), []);
+ assert.deepStrictEqual(rulesFor(".card { transform: scale(1.05); }\n"), []);
+});
+
test("hover-scale flags a standalone translate lift, not zero, downward, x-only, or longer property names", () => {
const rulesFor = (src) => scanSource(src, "a.css", { kind: "web" }).map((f) => f.rule);
// Issue #195: the repro.