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 PascalCase kit cards like IonCard, VCard, QCard and ElCard in nested-cards (#261)

tarekooooooo5e29642c09f5
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 8e55935..d9bb155 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -990,7 +990,7 @@ const rules = [
const hits = [];
if (stack === "js" || stack === "web") {
// 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)) {
+ for (const m of matches(/<(Card|IonCard|ion-card|VCard|v-card|mat-card|QCard|q-card|ElCard|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 e4d5283..d17f4c0 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1308,6 +1308,32 @@ test("focus-removed flags outline-style: none and outlineStyle: \"none\" (issue
assert.deepStrictEqual(lines("input:focus { outline-style: none; } input:focus-visible { outline: 2px solid blue; }\n", "field.css"), []);
});
+test("nested-cards flags PascalCase kit cards like IonCard, VCard, QCard and ElCard (issue #245)", () => {
+ const lines = (src, file = "Plans.tsx") => scanSource(src, file).filter((f) => f.rule === "nested-cards").map((f) => f.line);
+ const repro = [
+ 'import { IonCard, IonCardContent } from "@ionic/react";',
+ "",
+ "export function Plans() {",
+ " return (",
+ " <IonCard>",
+ " <IonCard>",
+ " <IonCardContent>Pro plan</IonCardContent>",
+ " </IonCard>",
+ " </IonCard>",
+ " );",
+ "}",
+ ].join("\n");
+ assert.deepStrictEqual(lines(repro), [5]);
+ for (const tag of ["VCard", "QCard", "ElCard"]) {
+ assert.deepStrictEqual(lines(`<template>\n <${tag}>\n <${tag}>Pro plan</${tag}>\n </${tag}>\n</template>\n`, "Plans.vue"), [2], tag);
+ }
+ // Card parts inside one card stay quiet.
+ assert.deepStrictEqual(lines("<IonCard>\n <IonCardHeader>Pro</IonCardHeader>\n <IonCardContent>Plan</IonCardContent>\n</IonCard>\n"), []);
+ assert.deepStrictEqual(lines("<template>\n <VCard>\n <VCardText>Pro</VCardText>\n </VCard>\n</template>\n", "Plans.vue"), []);
+ assert.deepStrictEqual(lines("<template>\n <QCard>\n <QCardSection>Pro</QCardSection>\n </QCard>\n</template>\n", "Plans.vue"), []);
+ assert.deepStrictEqual(lines("<template>\n <ElCard>\n <ElCardBody>Pro</ElCardBody>\n </ElCard>\n</template>\n", "Plans.vue"), []);
+});
+
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.