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.
JavaScript accessibilityagent-skillsagent-skills-toolsagentsagentskillsai-slopclaudeclaude-codeclaude-skillsexpoflutterfrontendionicjetpack-composemobilereact-nativeswiftuiuiuxvibe-coding
fix(detect): read 0xRRGGBB colors alongside 0xFFRRGGBB (#42) (#62)
Nguyễn Tuấn Anhb011700bd381
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex 7ade6e4..df35f40 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -64,15 +64,16 @@ function hexToHsl(hex) {// Six-digit hex colors in a snippet: #RRGGBB, 0xFFRRGGBB, Color(0xRRGGBB),// and #AARRGGBB in Android XML. #RRGGBBAA drops its alpha, and the short// forms expand (#RGB -> #RRGGBB, #RGBA -> #RRGGBB) so alpha and short-// colors are read the same way as #RRGGBB.+// colors are read the same way as #RRGGBB. 0xRRGGBB is read too, after the+// 0xFF form, so an eight-digit 0xFFRRGGBB is never misread as 0xFFRRGG.function hexColors(snippet, stack) {const out = [];const re = stack === "xml"- ? /#(?:[0-9a-fA-F]{2})?([0-9a-fA-F]{6})\b|0x[fF]{2}([0-9a-fA-F]{6})\b/g- : /#([0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b|0x[fF]{2}([0-9a-fA-F]{6})\b/g;+ ? /#(?:[0-9a-fA-F]{2})?([0-9a-fA-F]{6})\b|0x[fF]{2}([0-9a-fA-F]{6})\b|0x([0-9a-fA-F]{6})\b/g+ : /#([0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b|0x[fF]{2}([0-9a-fA-F]{6})\b|0x([0-9a-fA-F]{6})\b/g;let m;while ((m = re.exec(snippet))) {- let hex = m[1] || m[2];+ let hex = m[1] || m[2] || m[3];if (hex.length === 8) hex = hex.slice(0, 6);else if (hex.length === 4) hex = hex.slice(0, 3).split("").map((c) => c + c).join("");else if (hex.length === 3) hex = hex.split("").map((c) => c + c).join("");diff --git a/test/detect.test.js b/test/detect.test.jsindex d620364..6689139 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -218,6 +218,21 @@ test("slop-gradient reads Android #AARRGGBB colors", () => {assert.deepStrictEqual(scanSource(scrim, "a.css"), []);});+test("0xRRGGBB colors are read alongside 0xFFRRGGBB", () => {+ // Issue #42: the common Swift form Color(hex: 0x7C3AED) was missed.+ const shadow = 'Text("x").shadow(color: Color(hex: 0x7C3AED), radius: 20)\n';+ assert.deepStrictEqual(scanSource(shadow, "a.swift").map((f) => f.rule), ["glow-shadow"]);+ const shadowFF = 'Text("x").shadow(color: Color(hex: 0xFF7C3AED), radius: 20)\n';+ assert.deepStrictEqual(scanSource(shadowFF, "a.swift").map((f) => f.rule), ["glow-shadow"]);+ const gradient = "LinearGradient(gradient: Gradient(colors: [Color(hex: 0x7C3AED), Color(hex: 0xEC4899)]), startPoint: .top, endPoint: .bottom)\n";+ assert.deepStrictEqual(scanSource(gradient, "a.swift").map((f) => f.rule), ["slop-gradient"]);+ // Neutral 6-digit colors stay quiet, and an 8-digit gray is not misread as pink.+ const gray = 'Text("x").shadow(color: Color(hex: 0x9CA3AF), radius: 20)\n';+ assert.deepStrictEqual(scanSource(gray, "a.swift"), []);+ const grayFF = 'Text("x").shadow(color: Color(hex: 0xFF808080), radius: 20)\n';+ assert.deepStrictEqual(scanSource(grayFF, "a.swift"), []);+});+test("hexColors reads #RRGGBBAA, #RGB and #RGBA (issue #41)", () => {const shadow = ".card { box-shadow: 0 0 24px #7c3aed80; }\n";assert.deepStrictEqual(scanSource(shadow, "a.css").map((f) => f.rule), ["glow-shadow"]);