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.
JavaScript accessibilityagent-skillsagent-skills-toolsagentsagentskillsai-slopclaudeclaude-codeclaude-skillsexpoflutterfrontendionicjetpack-composemobilereact-nativeswiftuiuiuxvibe-coding
fix(detect): check Astro's Picture component in img-no-alt (#272)
Papito0846562f0d7cecb
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex 7c2629e..ac256e6 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -1454,10 +1454,11 @@ const rules = [// Vuetify renders <v-img> / <VImg> as an <img> too (#229).// Ionic renders <ion-img> / <IonImg> as an <img> too (#235).// 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)) {+ // Astro renders <Picture> as an <img> too (#268).+ for (const m of matches(/<(?:img|Image|Picture|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;+ if ((tag.startsWith("<Image") || tag.startsWith("<Picture")) && !/\ssrc\s*=/.test(tag)) continue;const hasAlt = /[\s:\[.]alt\]?\s*=|\{\s*alt\s*\}|\{\s*\.\.\./.test(tag)|| (stack === "web" && /\salt(?=[\s/>]|$)/.test(tag));if (!hasAlt) hits.push(m.index);diff --git a/test/detect.test.js b/test/detect.test.jsindex 7e7b2f8..18911f8 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -1474,6 +1474,32 @@ test("img-no-alt flags Quasar's q-img and Element Plus's el-image without alt",assert.deepStrictEqual(altLines('<el-image-viewer src="/hero.png" />\n'), []);});+test("img-no-alt flags Astro's Picture component without alt (issue #268)", () => {+ const altLines = (src, file = "Hero.astro") => scanSource(src, file, { kind: "web" }).filter((f) => f.rule === "img-no-alt").map((f) => f.line);+ // Issue #268 repro:+ const repro = [+ "---",+ 'import { Picture } from "astro:assets";',+ 'import hero from "../hero.png";',+ "---",+ '<Picture src={hero} formats={["avif", "webp"]} />',+ ].join("\n");+ assert.deepStrictEqual(altLines(repro), [5]);++ // Alt forms stay quiet+ assert.deepStrictEqual(altLines('<Picture src={hero} alt="Team photo" />\n'), []);+ assert.deepStrictEqual(altLines('<Picture src={hero} alt="" />\n'), []);+ assert.deepStrictEqual(altLines('<Picture src={hero} alt={caption} />\n'), []);+ assert.deepStrictEqual(altLines('<Picture src={hero} {...props} />\n'), []);++ // HTML <picture> is lowercase and handled by its child <img>+ assert.deepStrictEqual(altLines('<picture><img src="/hero.png" alt="Hero" /></picture>\n'), []);++ // Missing src or unrelated component starting with Picture stays quiet+ assert.deepStrictEqual(altLines('<Picture formats={["avif"]} />\n'), []);+ assert.deepStrictEqual(altLines('<PictureFrame items={items} />\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.