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 Gatsby's StaticImage and GatsbyImage in img-no-alt (#295)
Pranav Arya8649a241c54b
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex 2d67d38..a166854 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -1460,7 +1460,8 @@ const rules = [// 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).// 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)) {+ // So do Gatsby's <StaticImage> and <GatsbyImage> from gatsby-plugin-image (#285).+ 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|StaticImage|GatsbyImage)(?=[\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.jsindex de95c4f..a5e2dc4 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -1588,6 +1588,37 @@ test("img-no-alt flags Astro's Picture component without alt (issue #268)", () =assert.deepStrictEqual(altLines('<PictureFrame items={items} />\n'), []);});+test("img-no-alt flags Gatsby's StaticImage and GatsbyImage without alt (issue #285)", () => {+ const altLines = (src, file = "Hero.jsx") => scanSource(src, file, { kind: "web" }).filter((f) => f.rule === "img-no-alt").map((f) => f.line);+ // Issue #285 repro: the tags are flagged, the import line is not.+ const repro = [+ 'import { StaticImage, GatsbyImage } from "gatsby-plugin-image";',+ "",+ "export const Hero = ({ image }) => (",+ " <>",+ ' <StaticImage src="../images/hero.png" />',+ " <GatsbyImage image={image} />",+ " </>",+ ");",+ ].join("\n");+ assert.deepStrictEqual(altLines(repro), [5, 6]);+ assert.deepStrictEqual(altLines(repro, "Hero.tsx"), [5, 6]);++ // Alt forms stay quiet+ for (const open of ['<StaticImage src="../images/hero.png"', "<GatsbyImage image={image}"]) {+ assert.deepStrictEqual(altLines(`${open} alt="Hero" />\n`), [], open);+ assert.deepStrictEqual(altLines(`${open} alt="" />\n`), [], open);+ assert.deepStrictEqual(altLines(`${open} alt={title} />\n`), [], open);+ assert.deepStrictEqual(altLines(`${open} {...props} />\n`), [], open);+ // Other props do not stand in for alt+ assert.deepStrictEqual(altLines(`${open} placeholder="blurred" layout="fullWidth" />\n`), [1], open);+ }++ // A component whose name only starts the same way stays quiet+ assert.deepStrictEqual(altLines('<StaticImageGrid items={items} />\n'), []);+ assert.deepStrictEqual(altLines('<GatsbyImageList 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.