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 Nuxt Image's NuxtImg and NuxtPicture without alt (#210)

susheelg11974af805d289c1
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index bb6333f..a39fd93 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1441,7 +1441,8 @@ const rules = [
fix: "Describe what the image shows, or use alt=\"\" for pure decoration.",
find({ code, stack }) {
const hits = [];
- for (const m of matches(/<(?:img|Image)(?=[\s/>])/, code)) {
+ // Nuxt Image renders <NuxtImg> / <NuxtPicture>, also written kebab-case (#203).
+ for (const m of matches(/<(?:img|Image|NuxtImg|NuxtPicture|nuxt-img|nuxt-picture)(?=[\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 fa22dc4..dbc07c7 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -1276,6 +1276,16 @@ test("img-no-alt accepts Angular [alt] bindings and Svelte {alt} shorthand", ()
assert.deepStrictEqual(rulesFor("<img {src} />\n", "A.svelte"), ["img-no-alt"]);
});
+test("img-no-alt flags Nuxt Image's NuxtImg and NuxtPicture without alt, also kebab-case", () => {
+ const altLines = (src) => scanSource(src, "Hero.vue", { kind: "web" }).filter((f) => f.rule === "img-no-alt").map((f) => f.line);
+ // Issue #203: the repro.
+ assert.deepStrictEqual(altLines('<template>\n <NuxtImg src="/hero.png" />\n <NuxtPicture src="/team.png" />\n</template>\n'), [2, 3]);
+ assert.deepStrictEqual(altLines('<nuxt-img src="/hero.png" />\n<nuxt-picture src="/team.png" />\n'), [1, 2]);
+ assert.deepStrictEqual(altLines('<NuxtImg src="/hero.png" alt="Team photo" />\n'), []);
+ assert.deepStrictEqual(altLines('<NuxtPicture src="/divider.png" alt="" />\n'), []);
+ assert.deepStrictEqual(altLines('<nuxt-img :src="photo.url" :alt="photo.caption" />\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.