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): count Tailwind backdrop-blur classes toward glass-everywhere (#89)

Nguyễn Tuấn Anhedebc0353fca
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 1f19ef6..801275c 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -491,7 +491,10 @@ const rules = [
message: "Blur and glass used on several surfaces in one file.",
fix: "Keep system materials behind bars and sheets. Make content surfaces opaque.",
find({ code }) {
- const all = [...matches(/\.(?:ultraThin|thin|regular|thick|ultraThick)Material\b|<BlurView\b|backdrop-filter|BackdropFilter\(|ImageFilter\.blur|\.glassEffect\(/, code)];
+ // Tailwind: backdrop-blur, backdrop-blur-<size> and backdrop-blur-[...]
+ // count as blur surfaces. backdrop-blur-none removes the blur, so it
+ // does not count.
+ const all = [...matches(/\.(?:ultraThin|thin|regular|thick|ultraThick)Material\b|<BlurView\b|backdrop-filter|BackdropFilter\(|ImageFilter\.blur|\.glassEffect\(|\bbackdrop-blur(?!-none\b)/, code)];
return all.length >= 3 ? [all[0].index] : [];
},
},
diff --git a/test/detect.test.js b/test/detect.test.js
index 6c43e50..6ddb527 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -715,3 +715,33 @@ test("glow-shadow flags #0000ff and a saturated second color in a shadow list, b
].join("\n");
assert.deepStrictEqual(scanSource(notFlagged, "a.tsx"), []);
});
+
+test("glass-everywhere counts Tailwind backdrop-blur classes", () => {
+ // The three lines from issue #50.
+ const flagged = [
+ '<div className="backdrop-blur-xl bg-white/10">a</div>',
+ '<div className="backdrop-blur-md bg-black/20">b</div>',
+ '<div className="backdrop-blur-lg bg-white/5">c</div>',
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(flagged, "a.tsx").map((f) => f.rule), ["glass-everywhere"]);
+
+ // Two blur surfaces are not enough.
+ const two = flagged.split("\n").slice(0, 2).join("\n");
+ assert.deepStrictEqual(scanSource(two, "a.tsx"), []);
+
+ // Bare and arbitrary-value classes count too.
+ const mixed = [
+ '<div className="backdrop-blur">a</div>',
+ '<div className="backdrop-blur-[8px]">b</div>',
+ '<div className="backdrop-blur-sm">c</div>',
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(mixed, "a.tsx").map((f) => f.rule), ["glass-everywhere"]);
+
+ // backdrop-blur-none removes the blur, so it does not count toward the three.
+ const withNone = [
+ '<div className="backdrop-blur-none">a</div>',
+ '<div className="backdrop-blur-md">b</div>',
+ '<div className="backdrop-blur-lg">c</div>',
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(withNone, "a.tsx"), []);
+});