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 Quasar q-card and Element Plus el-card in nested-cards (#241)

Papito084751bc5f5327d
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index d04738a..ec36549 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -989,8 +989,8 @@ const rules = [
find({ code, stack }) {
const hits = [];
if (stack === "js" || stack === "web") {
- // Vuetify's v-card and Angular Material's mat-card nest like ion-card (#202).
- for (const m of matches(/<(Card|ion-card|v-card|mat-card)(?=[\s/>])/, code)) {
+ // Vuetify's v-card, Angular Material's mat-card, Quasar's q-card and Element Plus's el-card nest like ion-card (#202, #228).
+ for (const m of matches(/<(Card|ion-card|v-card|mat-card|q-card|el-card)(?=[\s/>])/, code)) {
const end = tagEnd(code, m.index + m[0].length);
if (end === -1) continue;
if (/\/\s*$/.test(code.slice(m.index + m[0].length, end))) continue;
diff --git a/test/detect.test.js b/test/detect.test.js
index 861054f..9cea177 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1255,6 +1255,20 @@ test("nested-cards flags Vuetify v-card and Angular Material mat-card nesting, n
assert.deepStrictEqual(cardLines(matParts, "plans.component.html"), []);
});
+test("nested-cards flags Quasar q-card and Element Plus el-card nesting, not their card parts (issue #228)", () => {
+ const cardLines = (src, file = "Plans.vue") => scanSource(src, file, { kind: "web" }).filter((f) => f.rule === "nested-cards").map((f) => [f.line, f.severity]);
+ // Issue #228 repro:
+ const quasar = '<template>\n <q-card>\n <q-card>Pro plan</q-card>\n </q-card>\n</template>\n';
+ assert.deepStrictEqual(cardLines(quasar), [[2, "noticeable"]]);
+
+ const elementPlus = '<template>\n <el-card>\n <el-card>Pro plan</el-card>\n </el-card>\n</template>\n';
+ assert.deepStrictEqual(cardLines(elementPlus), [[2, "noticeable"]]);
+
+ // Card parts inside one card stay quiet
+ const quasarParts = '<template>\n <q-card>\n <q-card-section>Pro</q-card-section>\n <q-card-actions><q-btn label="Go" /></q-card-actions>\n </q-card>\n</template>\n';
+ assert.deepStrictEqual(cardLines(quasarParts), []);
+});
+
test("nested-cards reads opening tags with tagEnd so arrows or > in props do not misread sibling cards", () => {
const rulesFor = (src, file = "a.tsx") => scanSource(src, file).filter((f) => f.rule === "nested-cards").map((f) => f.rule);
assert.deepStrictEqual(rulesFor("<Card onClick={() => open()} />\n<Card><p>Second</p></Card>\n"), []);