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 -webkit-backdrop-filter next to backdrop-filter once (#314)

daocuong110c1e53d07fd0
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index ce36cd9..a024493 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1029,7 +1029,20 @@ const rules = [
// 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] : [];
+ // A `-webkit-backdrop-filter` written next to the standard property is
+ // the same blur surface, not a second one (#298): the `backdrop-filter`
+ // inside `-webkit-backdrop-filter` already matches, so a standard
+ // `backdrop-filter` that follows the prefixed declaration in the same
+ // rule is dropped, and likewise a prefixed declaration that follows the
+ // standard one, so the pair counts once in either order. A lone
+ // prefixed declaration still counts.
+ const surfaces = all.filter((m) => {
+ if (code.slice(m.index - 8, m.index) === "-webkit-") {
+ return !/(?<!-webkit-)backdrop-filter\s*:[^{}]*$/.test(code.slice(0, m.index - 8));
+ }
+ return !/-webkit-backdrop-filter\s*:[^{}]*$/.test(code.slice(0, m.index));
+ });
+ return surfaces.length >= 3 ? [surfaces[0].index] : [];
},
},
{
diff --git a/test/detect.test.js b/test/detect.test.js
index db98dc2..c1c2957 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -2362,6 +2362,73 @@ test("glass-everywhere counts backdropFilter in JS style objects", () => {
assert.deepStrictEqual(scanSource(withNone, "a.tsx"), []);
});
+test("glass-everywhere counts a -webkit-backdrop-filter next to backdrop-filter once (issue #298)", () => {
+ // The repro from issue #298: two surfaces, each written with the Safari
+ // prefix next to the standard property, stay quiet.
+ const prefixed = [
+ ".nav {",
+ " -webkit-backdrop-filter: blur(12px);",
+ " backdrop-filter: blur(12px);",
+ "}",
+ ".modal {",
+ " -webkit-backdrop-filter: blur(20px);",
+ " backdrop-filter: blur(20px);",
+ "}",
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(prefixed, "glass.css"), []);
+
+ // Three surfaces written with both properties are still flagged.
+ const three = [
+ prefixed,
+ ".sheet {",
+ " -webkit-backdrop-filter: blur(8px);",
+ " backdrop-filter: blur(8px);",
+ "}",
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(three, "glass.css").map((f) => f.rule), ["glass-everywhere"]);
+
+ // Three surfaces with only the standard property are still flagged.
+ const plain = [
+ ".nav { backdrop-filter: blur(12px); }",
+ ".modal { backdrop-filter: blur(20px); }",
+ ".sheet { backdrop-filter: blur(8px); }",
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(plain, "glass.css").map((f) => f.rule), ["glass-everywhere"]);
+
+ // The same pair written standard-first also counts as one surface.
+ const reversed = [
+ ".nav {",
+ " backdrop-filter: blur(12px);",
+ " -webkit-backdrop-filter: blur(12px);",
+ "}",
+ ".modal {",
+ " backdrop-filter: blur(20px);",
+ " -webkit-backdrop-filter: blur(20px);",
+ "}",
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(reversed, "glass.css"), []);
+
+ const apart = [
+ ".nav { -webkit-backdrop-filter: blur(12px); background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(12px); }",
+ ".modal { backdrop-filter: blur(20px); color: white; -webkit-backdrop-filter: blur(20px); }",
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(apart, "glass.css"), []);
+
+ const prefixOnly = [
+ ".a { -webkit-backdrop-filter: blur(8px); }",
+ ".b { -webkit-backdrop-filter: blur(12px); }",
+ ".c { -webkit-backdrop-filter: blur(16px); }",
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(prefixOnly, "glass.css").map((f) => f.rule), ["glass-everywhere"]);
+
+ const mixed = [
+ ".a { -webkit-backdrop-filter: blur(8px); }",
+ ".b { backdrop-filter: blur(12px); }",
+ ".c { backdrop-filter: blur(16px); }",
+ ].join("\n");
+ assert.deepStrictEqual(scanSource(mixed, "glass.css").map((f) => f.rule), ["glass-everywhere"]);
+});
+
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),