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 Tailwind v4 outline-hidden in focus-removed (#148)

erdellll6603688f1943
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index c6a95f0..574532f 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1070,12 +1070,13 @@ const rules = [
fix: "Keep a visible :focus-visible style in the palette: a 2px outline or ring with an offset.",
find({ code, stack }) {
const hits = [];
- for (const m of matches(/["'`][^"'`\n]*\b(?:focus:)?outline-none\b[^"'`\n]*["'`]/, code)) {
+ for (const m of matches(/["'`][^"'`\n]*\b(?:focus:)?outline-(?:none|hidden)\b[^"'`\n]*["'`]/, code)) {
// Focus styles often sit in another string of the same cn(...) call.
const around = code.slice(Math.max(0, m.index - 400), m.index + m[0].length + 400);
- // The matched token itself may be `focus:outline-none`; its `focus:`
- // must not count as the replacement focus style it is missing.
- const withoutMatch = around.replace(/\bfocus:outline-none\b/g, "");
+ // The removal token itself, with any variants (`focus:outline-none`,
+ // Tailwind v4's `focus-visible:outline-hidden`), must not count as the
+ // replacement focus style it is missing.
+ const withoutMatch = around.replace(/(?<![\w:-])(?:[\w-]+:)*outline-(?:none|hidden)\b/g, "");
if (/\b(?:focus|focus-visible|focus-within|group-focus-visible|peer-focus-visible):|data-\[(?:highlighted|selected|focus|focused)|aria-selected:|data-\[state=/.test(withoutMatch)) continue;
hits.push(m.index);
}
diff --git a/test/detect.test.js b/test/detect.test.js
index 3509d35..840f181 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -871,6 +871,20 @@ test("focus-removed flags a bare focus:outline-none, not one with a ring replace
assert.deepStrictEqual(rulesFor('<input className="focus:outline-none focus-visible:ring-2" />\n'), []);
});
+test("focus-removed treats Tailwind v4 outline-hidden like outline-none", () => {
+ const rulesFor = (src, file = "a.tsx") => scanSource(src, file).map((f) => f.rule);
+ assert.deepStrictEqual(rulesFor('<input className="rounded border px-3 focus:outline-hidden" />\n'), ["focus-removed"]);
+ assert.deepStrictEqual(rulesFor('<input className="outline-hidden" />\n'), ["focus-removed"]);
+ assert.deepStrictEqual(rulesFor('<input class="rounded border px-3 focus:outline-hidden" />\n', "Input.html"), ["focus-removed"]);
+ // A replacement focus style keeps it quiet; focus:outline-hidden itself is not one.
+ assert.deepStrictEqual(rulesFor('<input className="focus:outline-hidden focus-visible:ring-2" />\n'), []);
+ assert.deepStrictEqual(rulesFor('<input className="focus:outline-hidden focus:ring-2" />\n'), []);
+ // A variant on the removal itself is not a replacement focus style.
+ assert.deepStrictEqual(rulesFor('<input className="focus-visible:outline-hidden" />\n'), ["focus-removed"]);
+ assert.deepStrictEqual(rulesFor('<input className="focus-visible:outline-none" />\n'), ["focus-removed"]);
+ assert.deepStrictEqual(rulesFor('<input className="focus-visible:outline-hidden focus-visible:ring-2" />\n'), []);
+});
+
test("nested-cards ignores dotted subcomponents and ion-card parts, still flags a real nested card", () => {
const rulesFor = (src, file = "a.tsx") => scanSource(src, file).map((f) => f.rule);
// Issue #65: dotted subcomponents of a single card are not nested cards.