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 backdropFilter in JS style objects in glass-everywhere (#289)

Dylan Duan79cc1a15924b
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 515e2da..bc35604 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1024,8 +1024,9 @@ const rules = [
find({ 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)];
+ // does not count. backdropFilter in a JS style object counts the same
+ // way, except backdropFilter: "none".
+ const all = [...matches(/\.(?:ultraThin|thin|regular|thick|ultraThick)Material\b|<BlurView\b|backdrop-filter|BackdropFilter\(|ImageFilter\.blur|\.glassEffect\(|\bbackdrop-blur(?!-none\b)|\bbackdropFilter\b(?!\s*:\s*["'`]none["'`])/, code)];
return all.length >= 3 ? [all[0].index] : [];
},
},
diff --git a/test/detect.test.js b/test/detect.test.js
index 5fd9229..0e76f3d 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -2159,6 +2159,29 @@ test("glass-everywhere counts Tailwind backdrop-blur classes", () => {
assert.deepStrictEqual(scanSource(withNone, "a.tsx"), []);
});
+test("glass-everywhere counts backdropFilter in JS style objects", () => {
+ // The repro from issue #288.
+ const flagged = [
+ 'const glass = { backdropFilter: "blur(12px)", background: "rgba(255,255,255,0.1)" };',
+ "export const Nav = () => <nav style={glass}>Nav</nav>;",
+ 'export const Card = () => <div style={{ backdropFilter: "blur(16px)" }}>Card</div>;',
+ 'export const Modal = () => <div style={{ backdropFilter: "blur(20px)" }}>Modal</div>;',
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(flagged, "Glass.tsx").map((f) => f.rule), ["glass-everywhere"]);
+
+ // Two blur surfaces are not enough.
+ const two = flagged.split("\n").slice(0, 3).join("\n");
+ assert.deepStrictEqual(scanSource(two, "Glass.tsx"), []);
+
+ // backdropFilter: "none" removes the blur, so it does not count toward the three.
+ const withNone = [
+ "<div style={{ backdropFilter: 'none' }}>a</div>",
+ '<div style={{ backdropFilter: "blur(16px)" }}>b</div>',
+ '<div style={{ backdropFilter: "blur(20px)" }}>c</div>',
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(withNone, "a.tsx"), []);
+});
+
test("tracked-caps-label catches leading-dot Tailwind tracking and rem letter-spacing", () => {
assert.deepStrictEqual(
scanSource('<p className="uppercase tracking-[.2em]">Features</p>', "Eyebrow.tsx").map((f) => f.rule),