BedrockStreaming / eslint-plugin-m6web-i18n

ESLint plugin for i18n

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No-text-as-attribute requires translation for empty text

alex-pex opened this issue · comments

If I write <img src="icon.png" /> I get img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.eslint (jsx-a11y/alt-text)

But If I change it to <img alt="" src="icon.png" /> I get Untranslated JSX attribute alt with "" eslint(m6web-i18n/no-text-as-attribute)


Maybe no-text-as-attribute should accept empty values, or a list of whitelisted values ?

Accessibility is a thing 😊. My opinion is that it should never be empty.

😁😁😁

Can't agree more with @mfrachet

If the content that the image conveys is presented within text in the surrounding context of the image, then an empty alt attribute may suffice.

From https://webaim.org/techniques/alttext/#example1 (look at example 2) -- WebAIM (Web Accessibility In Mind) has provided comprehensive web accessibility solutions since 1999.

There are use cases where alt can be empty and still be perfectly accessible. The plugin doesn't allow to do that

Totally agree with this.

There are plenty of sites contradicting each other on that topic.

I only provide you my thoughts and it s up to you to decide : for me it can exist empty alts for only visual elements like something that exist only for animation purpose and that has no meaning at all.

But you may probably talk about your actual need with @Slashgear and share together ☺️

I think you're wrong.

  • alt="Logo of X Company" is read as "Image : Logo of X Company"
  • missing alt is read as "Image ... (and nothing more)"
  • alt="" is ignored by screen reader.

Maybe you prefer to describe all images but when image have nothing to tell, there's no reason to waste time of people who need screen reader. I don't know if you already try to navigate with screen reader but if no, do it once. You'll see how it's long and boring. With small efforts of devs (like providing smart alt only when it's useful), we can make their navigation easier, so why not helping them ?

I already did the fix on a fork (1 line change), I can submit a PR if you agree with