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 Qwik onClick$ handlers in clickable-div (#179)

K L Aadithya8bb09158e7af
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 54bc83d..0d34a5e 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1220,9 +1220,9 @@ const rules = [
// Only this element's own attributes: a nested element inside {...} is checked on its own.
let top = m[0];
walkTag(code, m.index + m[0].length, (i) => { top += code[i]; });
- // onClick/onclick (React, HTML), @click/v-on:click (Vue, Alpine), x-on:click (Alpine),
- // on:click (Svelte) and (click) (Angular).
- if (!/\s(?:(?:on[cC]lick|@click|v-on:click|x-on:click|on:click)(?:\.[\w-]+|\|\w+)*|\(click\))\s*=/.test(top)) continue;
+ // onClick/onclick (React, HTML), onClick$ (Qwik), @click/v-on:click (Vue, Alpine),
+ // x-on:click (Alpine), on:click (Svelte) and (click) (Angular).
+ if (!/\s(?:(?:on[cC]lick\$?|@click|v-on:click|x-on:click|on:click)(?:\.[\w-]+|\|\w+)*|\(click\))\s*=/.test(top)) continue;
if (/^<a\b/.test(tag) && /(?:^|[\s{:[])href\]?\s*=/.test(tag)) continue;
// A non-semantic clickable element (or href-less anchor) is only
// keyboard- and screen-reader-accessible when it has both an
diff --git a/test/detect.test.js b/test/detect.test.js
index 1eae026..8740bfb 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1588,6 +1588,21 @@ test("clickable-div flags Angular (click) and Alpine x-on:click handlers", () =>
assert.deepStrictEqual(rulesFor('<button x-on:click="open = true">x</button>\n'), []);
});
+test("clickable-div flags Qwik onClick$ handlers (issue #178)", () => {
+ const lines = (src) => scanSource(src, "card.tsx").filter((f) => f.rule === "clickable-div").map((f) => f.line);
+ const card = 'export default function Card() {\n return <div class="card" onClick$={() => open()}>Details</div>;\n}\n';
+ assert.deepStrictEqual(lines(card), [2]);
+ for (const tag of ["div", "span", "li", "td", "a"]) {
+ assert.deepStrictEqual(lines(`<${tag} onClick$={() => open()}>x</${tag}>\n`), [1], tag);
+ }
+ assert.deepStrictEqual(lines('<img src="/a.png" alt="A" onClick$={() => open()} />\n'), [1]);
+ // The exemptions still apply: an anchor with href, or an interactive role and tabIndex.
+ assert.deepStrictEqual(lines('<div role="button" tabIndex={0} onClick$={() => open()}>Open</div>\n'), []);
+ assert.deepStrictEqual(lines('<a href="/details" onClick$={() => track()}>Details</a>\n'), []);
+ assert.deepStrictEqual(lines('<div role="button" onClick$={() => open()}>Open</div>\n'), [1]);
+ assert.deepStrictEqual(lines('<button onClick$={() => open()}>Open</button>\n'), []);
+});
+
test("template-theme flags create-vite's #646cff and #535bf2", () => {
const rulesFor = (src) => scanSource(src, "index.css").map((f) => f.rule).filter((r) => r === "template-theme");
assert.deepStrictEqual(rulesFor("a {\n font-weight: 500;\n color: #646cff;\n}\na:hover {\n color: #535bf2;\n}\n"), ["template-theme"]);