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): detect Tailwind colored and arbitrary glow shadows (#36)

Kemal Codesa3dca733ed8f
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 58a1963..de8839c 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -285,12 +285,12 @@ const rules = [
fix: "Shadows carry depth, not color: use the platform elevation or a soft neutral shadow, or remove it.",
find({ code }) {
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]+)/, 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*0\s*,\s*0/i.test(value)) continue;
+ 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 rgb = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(value);
+ 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 623d47e..445c3cd 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -305,3 +305,26 @@ test("the installer rejects an unknown flag before it copies anything", () => {
fs.rmSync(home, { recursive: true, force: true });
}
});
+
+test("glow-shadow catches Tailwind colored and arbitrary shadows while ignoring neutral shadows", () => {
+ const flagged = [
+ '<div className="shadow-2xl shadow-purple-500/50">x</div>',
+ '<div className="shadow-[0_0_40px_rgba(124,58,237,0.5)]">x</div>',
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(flagged, "a.tsx").map((f) => f.rule), ["glow-shadow", "glow-shadow"]);
+
+ for (const color of ["purple", "violet", "indigo", "pink", "fuchsia", "blue", "cyan", "teal"]) {
+ assert.deepStrictEqual(
+ scanSource(`<div className="shadow-${color}-500/40">x</div>`, "a.tsx").map((f) => f.rule),
+ ["glow-shadow"],
+ );
+ }
+
+ const neutral = [
+ '<div className="shadow-lg">x</div>',
+ '<div className="shadow-black/20">x</div>',
+ '<div className="shadow-gray-900/10">x</div>',
+ '<div className="shadow-[0_2px_8px_rgba(0,0,0,0.2)]">x</div>',
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(neutral, "a.tsx"), []);
+});