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 transition shorthands with no property (#149)

erdellll0218a24a4484
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 574532f..1781fa2 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -960,7 +960,10 @@ const rules = [
// In a CSS-in-JS value the scan stops at the closing quote, so
// `pointerEvents: "all"` later in the same style object is not read
// as part of `transition: "opacity .2s"`.
- const first = matches(/\btransition-all\b|transition(?:-property)?:\s*["'`]?[^;{}"'`]*?(?<![\w-])all(?![\w-])/, code).next();
+ // A shorthand whose first layer names no property (`transition: .3s
+ // ease`, `transition: ease-in 200ms`) defaults to `all` as well; the
+ // whole layer must be timing values, so `.2s opacity` stays quiet.
+ const first = matches(/\btransition-all\b|transition(?:-property)?:\s*["'`]?[^;{}"'`]*?(?<![\w-])all(?![\w-])|(?<![\w-])transition:\s*["'`]?\s*(?:(?:ease(?:-in-out|-in|-out)?|linear(?:\([^)]*\))?|step-start|step-end|(?:cubic-bezier|steps)\([^)]*\)|allow-discrete|normal)\s+)*\d*\.?\d+m?s\b(?:\s+(?:(?:ease(?:-in-out|-in|-out)?|linear(?:\([^)]*\))?|step-start|step-end|(?:cubic-bezier|steps)\([^)]*\)|allow-discrete|normal)|\d*\.?\d+m?s\b))*\s*(?=[,;}"'`\n]|$)/, code).next();
return first.done ? [] : [first.value.index];
},
},
diff --git a/test/detect.test.js b/test/detect.test.js
index 840f181..36b939d 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -394,6 +394,28 @@ 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("transition-all flags a shorthand that names no property, since it defaults to all", () => {
+ const rulesFor = (src, file = "a.css") => scanSource(src, file).map((f) => f.rule);
+ assert.deepStrictEqual(rulesFor(".card {\n transition: 0.3s ease;\n}\n"), ["transition-all"]);
+ assert.deepStrictEqual(rulesFor(".card { transition: .2s; }\n"), ["transition-all"]);
+ assert.deepStrictEqual(rulesFor(".card { transition: 200ms; }\n"), ["transition-all"]);
+ assert.deepStrictEqual(rulesFor(".card { transition: ease-in-out 200ms; }\n"), ["transition-all"]);
+ assert.deepStrictEqual(rulesFor(".card { transition: cubic-bezier(0.4, 0, 0.2, 1) .3s; }\n"), ["transition-all"]);
+ assert.deepStrictEqual(rulesFor('const s = { transition: "0.3s ease" };\n', "a.tsx"), ["transition-all"]);
+ // A named property, `none`, or a list of named properties stays quiet.
+ assert.deepStrictEqual(rulesFor(".card { transition: opacity .2s ease; }\n"), []);
+ assert.deepStrictEqual(rulesFor(".card { transition: none; }\n"), []);
+ assert.deepStrictEqual(rulesFor(".card { transition: transform 200ms, opacity 200ms; }\n"), []);
+ assert.deepStrictEqual(rulesFor(".card { transition-duration: .3s; }\n"), []);
+ assert.deepStrictEqual(rulesFor('const s = { transition: "opacity .2s", pointerEvents: "all" };\n', "a.tsx"), []);
+ // A property may come after the duration or timing function, still naming it.
+ assert.deepStrictEqual(rulesFor(".card { transition: .2s opacity; }\n"), []);
+ assert.deepStrictEqual(rulesFor(".card { transition: ease-in 200ms transform; }\n"), []);
+ assert.deepStrictEqual(rulesFor(".card { transition: 200ms ease-out 50ms color, 1s opacity; }\n"), []);
+ // Duration plus delay with no property is still every property.
+ assert.deepStrictEqual(rulesFor(".card { transition: .2s ease 0.1s; }\n"), ["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";