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 and Element Plus images without alt (#256)

Indra Prasetyac4d640d6c0be
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 3890dbc..2f0bbc9 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1447,7 +1447,8 @@ const rules = [
// Nuxt Image renders <NuxtImg> / <NuxtPicture>, also written kebab-case (#203).
// Vuetify renders <v-img> / <VImg> as an <img> too (#229).
// Ionic renders <ion-img> / <IonImg> as an <img> too (#235).
- for (const m of matches(/<(?:img|Image|NuxtImg|NuxtPicture|nuxt-img|nuxt-picture|v-img|VImg|ion-img|IonImg)(?=[\s/>])/, code)) {
+ // Quasar renders <q-img> / <QImg> and Element Plus <el-image> / <ElImage> as <img> too (#249).
+ for (const m of matches(/<(?:img|Image|NuxtImg|NuxtPicture|nuxt-img|nuxt-picture|v-img|VImg|ion-img|IonImg|q-img|QImg|el-image|ElImage)(?=[\s/>])/, code)) {
const end = tagEnd(code, m.index);
const tag = code.slice(m.index, end === -1 ? undefined : end);
if (tag.startsWith("<Image") && !/\ssrc\s*=/.test(tag)) continue;
diff --git a/test/detect.test.js b/test/detect.test.js
index 9eb355c..fb572a9 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1385,6 +1385,18 @@ test("img-no-alt flags Ionic's ion-img and IonImg without alt (issue #235)", ()
assert.deepStrictEqual(altLines('<ion-img-viewer src="/hero.png" />\n'), []);
});
+test("img-no-alt flags Quasar's q-img and Element Plus's el-image without alt", () => {
+ const altLines = (src, file = "Gallery.vue") => scanSource(src, file, { kind: "web" }).filter((f) => f.rule === "img-no-alt").map((f) => f.line);
+ assert.deepStrictEqual(altLines('<template>\n <q-img src="/hero.png" />\n <QImg src="/team.png" />\n <el-image src="/group.png" />\n <ElImage src="/office.png" />\n</template>\n'), [2, 3, 4, 5]);
+ assert.deepStrictEqual(altLines('<q-img src="/hero.png" alt="Team photo" />\n'), []);
+ assert.deepStrictEqual(altLines('<QImg src="/hero.png" alt="" />\n'), []);
+ assert.deepStrictEqual(altLines('<el-image src="/hero.png" alt="Team photo" />\n'), []);
+ assert.deepStrictEqual(altLines('<ElImage src="/hero.png" alt="" />\n'), []);
+ assert.deepStrictEqual(altLines('<q-img :src="photo.url" :alt="photo.caption" />\n'), []);
+ assert.deepStrictEqual(altLines('<el-image :src="photo.url" :alt="photo.caption" />\n'), []);
+ assert.deepStrictEqual(altLines('<el-image-viewer src="/hero.png" />\n'), []);
+});
+
test("placeholder-label flags inputs that use a placeholder as their only label", () => {
const rulesFor = (src) => scanSource(src, "a.tsx").map((f) => f.rule);
// The issue's repro.