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): accept #FF alpha prefix in template-theme (#13) (#86)

Nguyễn Tuấn Anhb194eee9eba4
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 4a3e488..59d0749 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -374,8 +374,10 @@ const rules = [
stacks: null,
message: "The project template's default color is still the theme.",
fix: "Pick the brand's own accent and define semantic roles (background, surface, text, accent, destructive). Ask first if that purple has become the brand.",
- find({ code }) {
- const re = /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/;
+ 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);
},
},
diff --git a/test/detect.test.js b/test/detect.test.js
index 8f57541..c26492e 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -208,6 +208,10 @@ test("horizontal={false} is still a vertical list", () => {
test("Android color resources reach template-theme", () => {
const src = '<resources>\n <color name="purple_500">#6200EE</color>\n</resources>\n';
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(".a { color: #FF6200EE; }\n", "a.css"), []);
});
test("transition-all flags `all` anywhere in a transition list", () => {