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.

Check PrimeNG p-image for missing alt text (#308)

Ishan Gupta3e46fd17b230
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 8273642..aa6ac35 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1467,7 +1467,7 @@ const rules = [
// Astro renders <Picture> as an <img> too (#268).
// So do Gatsby's <StaticImage> and <GatsbyImage> from gatsby-plugin-image (#285).
// SvelteKit's <enhanced:img> from @sveltejs/enhanced-img renders an <img> too (#304).
- for (const m of matches(/<(?:img|enhanced:img|Image|Picture|NuxtImg|NuxtPicture|nuxt-img|nuxt-picture|v-img|VImg|ion-img|IonImg|q-img|QImg|el-image|ElImage|StaticImage|GatsbyImage)(?=[\s/>])/, code)) {
+ for (const m of matches(/<(?:img|enhanced:img|Image|Picture|NuxtImg|NuxtPicture|nuxt-img|nuxt-picture|v-img|VImg|ion-img|IonImg|q-img|QImg|el-image|ElImage|StaticImage|GatsbyImage|p-image)(?=[\s/>])/, code)) {
const end = tagEnd(code, m.index);
const tag = code.slice(m.index, end === -1 ? undefined : end);
if ((tag.startsWith("<Image") || tag.startsWith("<Picture")) && !/\ssrc\s*=/.test(tag)) continue;
diff --git a/test/detect.test.js b/test/detect.test.js
index fd858da..48cbcc9 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1562,6 +1562,18 @@ 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 checks PrimeNG p-image in Angular templates (issue #303)", () => {
+ const template = [
+ '<p-image src="/hero.png" width="250" preview />',
+ '<p-image src="/hero.png" alt="Hero" />',
+ '<p-image src="/decoration.png" alt="" />',
+ '<p-image src="/hero.png" [alt]="title" />',
+ '<p-image-compare />',
+ ].join("\n");
+ const findings = scanSource(template, "hero.component.html", { kind: "web" });
+ assert.deepStrictEqual(findings.filter((f) => f.rule === "img-no-alt").map((f) => f.line), [1]);
+});
+
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: