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 Flutter text Shadow(color: ...) in glow-shadow (#238)

Papito084b58fd11a5e3b
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 8c9a654..3d86be3 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -925,7 +925,7 @@ const rules = [
const hits = [];
// 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)) {
+ for (const m of matches(/\.shadow\(\s*color:\s*([^,)]+)|(?:shadowColor|textShadowColor)\s*[:=]\s*["']?([^"',;\n}]+)|(?:ambientColor|spotColor)\s*=\s*([^,)\n]+)|\b(?:BoxShadow|Shadow)\(\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 580f22d..fc549a3 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -2134,3 +2134,29 @@ test("slop-gradient reads Compose Color(red = ..., green = ..., blue = ...) stop
];
for (const stops of quiet) assert.deepStrictEqual(rulesFor(gradient(stops)), [], stops);
});
+
+test("glow-shadow flags Flutter text Shadow(color: ...), not neutral ones (issue #230)", () => {
+ const glowLines = (src, file = "title.dart") => scanSource(src, file).filter((f) => f.rule === "glow-shadow").map((f) => f.line);
+ // Issue #230 repro:
+ const repro = [
+ "import 'package:flutter/material.dart';",
+ "",
+ "const title = Text(",
+ " 'Pro',",
+ " style: TextStyle(",
+ " shadows: [Shadow(color: Colors.purple, blurRadius: 20)],",
+ " ),",
+ ");",
+ ].join("\n");
+ assert.deepStrictEqual(glowLines(repro, "title.dart"), [6]);
+
+ // Colored Shadow and BoxShadow
+ assert.deepStrictEqual(glowLines("const s = Shadow(color: Colors.purple, blurRadius: 20);\n"), [1]);
+ assert.deepStrictEqual(glowLines("const s = BoxShadow(color: Colors.purple, blurRadius: 20);\n"), [1]);
+ assert.deepStrictEqual(glowLines("const s = Shadow(color: Color(0xFF7C3AED), blurRadius: 16);\n"), [1]);
+
+ // Neutral cases stay quiet
+ assert.deepStrictEqual(glowLines("const s = Shadow(color: Colors.black26, blurRadius: 4);\n"), []);
+ assert.deepStrictEqual(glowLines("const s = Shadow(color: Color(0x42000000));\n"), []);
+ assert.deepStrictEqual(glowLines("const s = BoxShadow(color: Colors.black54, blurRadius: 4);\n"), []);
+});