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 bare focus:outline-none as focus-removed (#91)

Nguyễn Tuấn Anh738ee727f65c
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 142bd19..0b285f9 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -827,7 +827,10 @@ const rules = [
for (const m of matches(/["'`][^"'`\n]*\b(?:focus:)?outline-none\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);
- if (/\b(?:focus|focus-visible|focus-within|group-focus-visible|peer-focus-visible):|data-\[(?:highlighted|selected|focus|focused)|aria-selected:|data-\[state=/.test(around)) continue;
+ // 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, "");
+ 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);
}
if ((stack === "css" || stack === "web") && !/focus-visible/.test(code)) {
diff --git a/test/detect.test.js b/test/detect.test.js
index 4c22532..a600d59 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -512,6 +512,15 @@ test("clickable-div flags a href-less anchor with onClick", () => {
assert.deepStrictEqual(findingsFor('<a onClick={go} tabIndex={0}>Go</a>\n').map((f) => f.rule), ["clickable-div"]);
});
+test("focus-removed flags a bare focus:outline-none, not one with a ring replacement", () => {
+ const rulesFor = (src) => scanSource(src, "a.tsx").map((f) => f.rule);
+ assert.deepStrictEqual(rulesFor('<input className="focus:outline-none" />\n'), ["focus-removed"]);
+ assert.deepStrictEqual(rulesFor('<input className="outline-none" />\n'), ["focus-removed"]);
+ // A replacement focus style in the same string (or nearby) keeps it quiet.
+ assert.deepStrictEqual(rulesFor('<input className="focus:outline-none focus:ring-2" />\n'), []);
+ assert.deepStrictEqual(rulesFor('<input className="focus:outline-none focus-visible:ring-2" />\n'), []);
+});
+
test("unverified-claim allows one adjective between the number and the noun", () => {
const rulesFor = (src) => scanSource(src, "a.tsx").map((f) => f.rule);
assert.deepStrictEqual(rulesFor("<p>Join 10,000+ customers</p>\n"), ["unverified-claim"]);