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): stop transition-all at the quote that ends a CSS-in-JS value (#49)

Dipesh Sapkotaba129b6226e4
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index bb7f888..79eaa0f 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -632,7 +632,10 @@ const rules = [
// `all` may sit anywhere in the list, not just first:
// `transition: color .2s, all .3s` counts, but a property name that
// merely starts with `all` (e.g. `all-in-one`) does not.
- const first = matches(/\btransition-all\b|transition(?:-property)?:[^;{}]*?(?<![\w-])all(?![\w-])/, code).next();
+ // 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();
return first.done ? [] : [first.value.index];
},
},
diff --git a/test/detect.test.js b/test/detect.test.js
index dafdefc..b0fb548 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -157,6 +157,19 @@ test("transition-all flags `all` anywhere in a transition list", () => {
assert.deepStrictEqual(scanSource(named, "a.css"), []);
});
+test("transition-all stops at the quote that ends a CSS-in-JS value", () => {
+ // `all` in a later property of a style object is not part of the transition.
+ const pointerEvents = 'const s = { transition: "opacity .2s", pointerEvents: "all" };\n';
+ assert.deepStrictEqual(scanSource(pointerEvents, "a.tsx").map((f) => f.rule), []);
+ const userSelect = 'const t = { transition: "opacity .2s", userSelect: "all" };\n';
+ assert.deepStrictEqual(scanSource(userSelect, "a.tsx").map((f) => f.rule), []);
+ // `all` inside the quoted transition value still counts.
+ const quotedList = 'const u = { transition: "color .2s, all .3s" };\n';
+ assert.deepStrictEqual(scanSource(quotedList, "a.tsx").map((f) => f.rule), ["transition-all"]);
+ const singleQuoted = "const v = { transition: 'all .2s' };\n";
+ assert.deepStrictEqual(scanSource(singleQuoted, "a.tsx").map((f) => f.rule), ["transition-all"]);
+});
+
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"]);