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 template-theme to catch Expo starter leftovers (#102)

Nguyễn Tuấn Anhbef5108a8a71
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index c3f1e19..1a37d67 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -404,8 +404,11 @@ const rules = [
find({ code, stack }) {
const re = stack === "xml"
? /#(?:[fF]{2})?(?:6200[eE][eE]|3700[bB]3|[bB][bB]86[fF][cC])\b/
- : /seedColor:\s*Colors\.deepPurple|0x[fF]{2}(?:6650[aA]4|[dD]0[bB][cC][fF][fF]|6200[eE][eE]|3700[bB]3|[bB][bB]86[fF][cC])\b|#(?:6200[eE][eE]|3700[bB]3|[bB][bB]86[fF][cC])\b/;
- return [...matches(re, code)].map((m) => m.index);
+ : /seedColor:\s*Colors\.deepPurple|0x[fF]{2}(?:6650[aA]4|[dD]0[bB][cC][fF][fF]|6200[eE][eE]|3700[bB]3|[bB][bB]86[fF][cC])\b|#(?:6200[eE][eE]|3700[bB]3|[bB][bB]86[fF][cC]|0[aA]7[eE][aA]4)\b|<HelloWave\b|<ParallaxScrollView\b/;
+ // One finding per file, like drawer-nav: the default tint and the
+ // starter-screen components are the same leftover.
+ const first = matches(re, code).next();
+ return first.done ? [] : [first.value.index];
},
},
{
diff --git a/test/detect.test.js b/test/detect.test.js
index d6e9cdc..2cec820 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -17,7 +17,7 @@ test("clean fixtures produce no findings", () => {
test("React Native slop is caught", () => {
const found = rulesIn("HomeScreen.tsx");
for (const id of [
- "slop-gradient", "gradient-text", "nested-cards", "status-dot", "unvirtualized-list",
+ "slop-gradient", "gradient-text", "template-theme", "nested-cards", "status-dot", "unvirtualized-list",
"fixed-text-size", "emoji-icon", "sparkle-icon", "oops-error", "buzzword-copy",
"welcome-back", "vague-button", "invented-stat", "glow-shadow", "hover-only",
"keyboard-cover", "back-gesture", "drawer-nav",
@@ -267,10 +267,22 @@ test("Android color resources reach template-theme", () => {
assert.deepStrictEqual(scanSource(src, "colors.xml").map((f) => f.rule), ["template-theme"]);
// Android Studio writes template colors with an alpha byte (#AARRGGBB).
const alpha = '<resources>\n <color name="purple_500">#FF6200EE</color>\n <color name="purple_700">#FF3700B3</color>\n</resources>\n';
- assert.deepStrictEqual(scanSource(alpha, "colors.xml").map((f) => f.rule), ["template-theme", "template-theme"]);
+ assert.deepStrictEqual(scanSource(alpha, "colors.xml").map((f) => f.rule), ["template-theme"]);
assert.deepStrictEqual(scanSource(".a { color: #FF6200EE; }\n", "a.css"), []);
});
+test("template-theme catches Expo starter leftovers", () => {
+ // Issue #74 repro: the default tint plus starter-screen imports.
+ const src = 'const tintColorLight = "#0a7ea4";\nimport { HelloWave } from "@/components/HelloWave";\nimport ParallaxScrollView from "@/components/ParallaxScrollView";\n';
+ assert.deepStrictEqual(scanSource(src, "Colors.ts", { kind: "mobile" }).map((f) => f.rule), ["template-theme"]);
+ // Imports alone stay quiet so the components can be kept on purpose.
+ const importsOnly = 'import { HelloWave } from "@/components/HelloWave";\nimport ParallaxScrollView from "@/components/ParallaxScrollView";\n';
+ assert.deepStrictEqual(scanSource(importsOnly, "HomeScreen.tsx", { kind: "mobile" }), []);
+ // JSX use in a screen is flagged, once per file.
+ const used = 'import { HelloWave } from "@/components/HelloWave";\nimport ParallaxScrollView from "@/components/ParallaxScrollView";\n\nexport function HomeScreen() {\n return (\n <ParallaxScrollView>\n <HelloWave />\n <HelloWave />\n </ParallaxScrollView>\n );\n}\n';
+ assert.deepStrictEqual(scanSource(used, "HomeScreen.tsx", { kind: "mobile" }).map((f) => f.rule), ["template-theme"]);
+});
+
test("transition-all flags `all` anywhere in a transition list", () => {
const flagged = ".x { transition: color .2s, all .3s; }\n";
assert.deepStrictEqual(scanSource(flagged, "a.css").map((f) => f.rule), ["transition-all"]);
diff --git a/test/fixtures/slop/HomeScreen.tsx b/test/fixtures/slop/HomeScreen.tsx
index 28dfccf..5ee14b5 100644
--- a/test/fixtures/slop/HomeScreen.tsx
+++ b/test/fixtures/slop/HomeScreen.tsx
@@ -10,6 +10,9 @@ export function HomeScreen({ items }) {
<Text>Welcome back!</Text>
<Text>Unlock your potential with seamless planning ✨</Text>
</LinearGradient>
+ <ParallaxScrollView>
+ <HelloWave />
+ </ParallaxScrollView>
<MaskedView maskElement={<Text>Pro</Text>} />
<Card>
<Card>