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 boxShadow and textShadow style keys in glow-shadow (#254)

daocuong114c6c30c7270f
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 51d15ec..3890dbc 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -925,9 +925,9 @@ 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]+)|\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)) {
+ 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]*\))*)\)|\b(?:box|text)Shadow\s*:\s*(?:"([^"\n]*)"|'([^'\n]*)'|`([^`]*)`)/, code)) {
const raw = m.slice(1).find(Boolean) || "";
- const layers = m[5] || m[7] ? glowLayers(raw.replace(/_/g, " ")) : raw ? [raw] : [];
+ const layers = m[5] || m[7] || m[9] || m[10] || m[11] ? glowLayers(raw.replace(/_/g, " ")) : raw ? [raw] : [];
if (layers.some((value) => isGlowValue(value, stack))) hits.push(m.index);
}
return hits;
diff --git a/test/detect.test.js b/test/detect.test.js
index 0b63be7..9eb355c 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1612,6 +1612,32 @@ test("glow-shadow skips inset accent bars with no blur (#111)", () => {
);
});
+test("glow-shadow flags boxShadow and textShadow in JS style objects (#251)", () => {
+ // Issue #251 repro: the flag lands on line 3, like the CSS box-shadow case.
+ const hero = [
+ "export function Hero() {",
+ " return (",
+ ' <div style={{ boxShadow: "0 0 40px rgba(124, 58, 237, 0.6)" }}>',
+ " Pro",
+ " </div>",
+ " );",
+ "}",
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(hero, "Hero.tsx").map((f) => [f.rule, f.line]), [["glow-shadow", 3]]);
+ // textShadow, single quotes, backticks, and a later key in the same object.
+ assert.deepStrictEqual(scanSource(`<div style={{ textShadow: '0 0 12px #7c3aed' }} />\n`, "a.tsx").map((f) => f.rule), ["glow-shadow"]);
+ assert.deepStrictEqual(scanSource("<div style={{ boxShadow: `0 0 40px #7c3aed` }} />\n", "a.tsx").map((f) => f.rule), ["glow-shadow"]);
+ assert.deepStrictEqual(
+ scanSource(`<div style={{ boxShadow: "0 0 40px rgba(124, 58, 237, 0.6)", color: "blue" }} />\n`, "a.tsx").map((f) => f.rule),
+ ["glow-shadow"],
+ );
+ assert.deepStrictEqual(scanSource("<div style={{ boxShadow: `0 0 ${blur}px #7c3aed` }} />\n", "a.tsx").map((f) => f.rule), ["glow-shadow"]);
+ assert.deepStrictEqual(scanSource("const glow = {\n boxShadow: `0 0 40px\n #7c3aed`,\n};\n", "a.ts").map((f) => [f.rule, f.line]), [["glow-shadow", 2]]);
+ // A neutral shadow stays quiet, and a later key is not read as part of it.
+ assert.deepStrictEqual(scanSource(`<div style={{ boxShadow: "0 1px 2px rgba(0, 0, 0, 0.1)" }} />\n`, "a.tsx"), []);
+ assert.deepStrictEqual(scanSource(`<div style={{ boxShadow: "0 1px 2px rgba(0, 0, 0, 0.1)", color: "#7c3aed" }} />\n`, "a.tsx").filter((f) => f.rule === "glow-shadow"), []);
+});
+
test("hover-scale flags Tailwind arbitrary scale values of 1.02 and above", () => {
const rulesFor = (src) => scanSource(src, "a.tsx").map((f) => f.rule);
// The issue's example line, plus the group- prefix variant.