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): catch Android shadowColor on one line or with alpha (#63)

Nguyễn Tuấn Anhf3234308444e
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 483d2d6..5c7c13f 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -292,13 +292,13 @@ const rules = [
stacks: null,
message: "Colored glow shadow.",
fix: "Shadows carry depth, not color: use the platform elevation or a soft neutral shadow, or remove it.",
- find({ code }) {
+ find({ code, stack }) {
const hits = [];
- for (const m of matches(/\.shadow\(\s*color:\s*([^,)]+)|shadowColor\s*[:=]\s*([^,;\n}]+)|(?:ambientColor|spotColor)\s*=\s*([^,)\n]+)|BoxShadow\(\s*color:\s*([^,)\n]+)|box-shadow:\s*([^;\n]+)|\bshadow-((?:purple|violet|indigo|pink|fuchsia|blue|cyan|teal)-\d{2,3})\b|\bshadow-\[([^\]\n]+)\]/, code)) {
+ for (const m of matches(/\.shadow\(\s*color:\s*([^,)]+)|shadowColor\s*[:=]\s*["']?([^"',;\n}]+)|(?:ambientColor|spotColor)\s*=\s*([^,)\n]+)|BoxShadow\(\s*color:\s*([^,)\n]+)|box-shadow:\s*([^;\n]+)|\bshadow-((?:purple|violet|indigo|pink|fuchsia|blue|cyan|teal)-\d{2,3})\b|\bshadow-\[([^\]\n]+)\]/, code)) {
const value = m.slice(1).find(Boolean) || "";
if (/black|gray|grey|shadow|\.primary\b|label|0x[0-9a-f]{2}000000|#000|rgba?\([\s_]*0(?:[\s_]*,[\s_]*|[\s_]+)0(?:[\s_]*,[\s_]*|[\s_]+)0/i.test(value)) continue;
const named = /(?:\.|Colors\.|Color\.|\b)(purple|deepPurple|indigo|violet|pink|magenta|fuchsia|blue|cyan|teal|mint|accentColor|accent)\b/i.test(value);
- const hex = hexColors(value).some(isSaturated);
+ const hex = hexColors(value, stack).some(isSaturated);
const rgb = /rgba?\([\s_]*(\d+)(?:[\s_]*,[\s_]*|[\s_]+)(\d+)(?:[\s_]*,[\s_]*|[\s_]+)(\d+)/.exec(value);
const rgbSat = rgb && Math.max(+rgb[1], +rgb[2], +rgb[3]) - Math.min(+rgb[1], +rgb[2], +rgb[3]) > 60;
if (named || hex || rgbSat) hits.push(m.index);
diff --git a/test/detect.test.js b/test/detect.test.js
index 563e7c1..7fa423c 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -598,3 +598,14 @@ test("hover-scale flags Tailwind arbitrary scale values of 1.02 and above", () =
// The named steps still work.
assert.deepStrictEqual(rulesFor('<div className="hover:scale-105">x</div>\n'), ["hover-scale"]);
});
+
+test("glow-shadow catches Android shadowColor on one line or with alpha", () => {
+ const oneLine = '<TextView android:shadowColor="#7C3AED" android:shadowRadius="20" />';
+ const multiLine = '<TextView\n android:shadowColor="#807C3AED"\n android:shadowRadius="20" />';
+ assert.deepStrictEqual(scanSource(oneLine, "a.xml").map((f) => f.rule), ["glow-shadow"]);
+ assert.deepStrictEqual(scanSource(multiLine, "a.xml").map((f) => f.rule), ["glow-shadow"]);
+
+ // Semi-transparent black is a neutral shadow, not a colored glow.
+ const neutral = '<TextView android:shadowColor="#80000000" android:shadowRadius="20" />';
+ assert.deepStrictEqual(scanSource(neutral, "a.xml"), []);
+});