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): flag colored text-shadow, drop-shadow() and textShadowColor in glow-shadow (#208)

susheelg119716759cbd0fb5
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index d416b61..bc7cb26 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -923,7 +923,9 @@ const rules = [
fix: "Shadows carry depth, not color: use the platform elevation or a soft neutral shadow, or remove it.",
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)) {
+ // text-shadow is layered like box-shadow (#200); textShadowColor is React
+ // Native's text glow (#201); a filter drop-shadow() is one shadow (#199).
+ for (const m of matches(/\.shadow\(\s*color:\s*([^,)]+)|(?:shadowColor|textShadowColor)\s*[:=]\s*["']?([^"',;\n}]+)|(?:ambientColor|spotColor)\s*=\s*([^,)\n]+)|BoxShadow\(\s*color:\s*([^,)\n]+)|(?:box|text)-shadow:\s*([^;\n]+)|\bshadow-((?:purple|violet|indigo|pink|fuchsia|blue|cyan|teal)-\d{2,3})\b|\bshadow-\[([^\]\n]+)\]|\bdrop-shadow\(((?:[^()\n]|\([^()\n]*\))*)\)/, code)) {
const raw = m.slice(1).find(Boolean) || "";
const layers = m[5] || m[7] ? glowLayers(raw.replace(/_/g, " ")) : raw ? [raw] : [];
if (layers.some((value) => isGlowValue(value, stack))) hits.push(m.index);
diff --git a/test/detect.test.js b/test/detect.test.js
index 09b7076..ea6c963 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1926,6 +1926,24 @@ test("glow-shadow checks each box-shadow layer independently so a neutral layer
for (const [src, file] of quiet) assert.deepStrictEqual(rulesFor(src, file), [], src);
});
+test("glow-shadow flags colored text-shadow, filter drop-shadow() and React Native textShadowColor, not neutral ones", () => {
+ const glowLines = (src, file = "a.css") => scanSource(src, file, { kind: "web" }).filter((f) => f.rule === "glow-shadow").map((f) => f.line);
+ // Issue #199: a colored drop-shadow() in filter, also after another filter function.
+ assert.deepStrictEqual(glowLines(".logo {\n filter: drop-shadow(0 0 20px #7c3aed);\n}\n"), [2]);
+ assert.deepStrictEqual(glowLines(".logo { filter: brightness(1.1) drop-shadow(0 0 12px rgb(124 58 237 / 0.6)); }\n"), [1]);
+ assert.deepStrictEqual(glowLines(".logo { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2)); }\n"), []);
+ // Issue #200: a colored text-shadow, also when only one layer is colored.
+ assert.deepStrictEqual(glowLines(".title {\n text-shadow: 0 0 20px #7c3aed;\n}\n"), [2]);
+ assert.deepStrictEqual(glowLines(".title { text-shadow: 0 1px 2px #000, 0 0 16px #7c3aed; }\n"), [1]);
+ assert.deepStrictEqual(glowLines(".title { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }\n"), []);
+ // Issue #201: React Native textShadowColor, next to the existing shadowColor case.
+ const rn = 'import { StyleSheet } from "react-native";\n\nconst styles = StyleSheet.create({\n title: { textShadowColor: "#7C3AED", textShadowRadius: 12 },\n});\n';
+ assert.deepStrictEqual(glowLines(rn, "Title.tsx"), [4]);
+ assert.deepStrictEqual(glowLines('const s = { textShadowColor: "rgba(0, 0, 0, 0.3)" };\n', "a.tsx"), []);
+ assert.deepStrictEqual(glowLines('const s = { textShadowColor: "#000" };\n', "a.tsx"), []);
+ assert.deepStrictEqual(glowLines('const s = { shadowColor: "#7C3AED", shadowRadius: 12 };\n', "a.tsx"), [1]);
+});
+
test("slop-gradient reads UIKit system colors like .systemPurple and .systemPink", () => {
const rulesFor = (src) => scanSource(src, "Hero.swift").map((f) => f.rule).filter((r) => r === "slop-gradient");
const gradient = (stops) => `LinearGradient(colors: [${stops}], startPoint: .leading, endPoint: .trailing)\n`;