-
-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
img-uses-alt does not allow empty string or possible empty string #6
Comments
I agree on the first one, since we can't determine the value of foo until runtime. However, not sure about the second - You can place a space in between the quotation marks ( |
I think the
|
Fixing first example in 0.5.3 - will upgrade minor on |
Awesome! Thanks again! |
0.5.3 published - should fix first use case + other bugs that are closed! |
I think this is still broken for cases like function Foo() {
return <img alt={foo.bar || ''} />;
} and function Foo() {
return <img alt={bar() || ''} />;
} and function Foo() {
return <img alt={foo.bar() || ''} />;
} |
Added test cases for those and fixed in v0.5.4 - still may be other edge cases, working on resolving cases to handle each type specified in spec |
Wonderful! |
@evcohen do you have an ETA on the |
This rule was giving the same error message for two different types of errors. This could lead to confusion, so I decided to make the error messages more descriptive. When jsx-eslint#6 is resolved, the empty alt value message should probably be expanded to provide guidance about using `role="presentation"`.
@lencioni waiting for ci build to pass and then publishing v0.6.0. Error message updated and this strictly allows only the following scenario bad:
|
I noticed that the Chrome audit rules allows |
Not sure what the real rule is in this case, but as a linter, I think it's better to be opinionated in a case like this or give users configuration options to manage the rigidity of the rule. My thinking is, the only time |
My reading of the text you posted agrees with the Chrome text I lined to, and it also fits my intuitive understanding. I think it makes sense to enforce the existence of |
After digging into this rule a little more with @evcohen, I believe that it is okay for images to have an empty string for alt text. I expect the next release of the linter rule to allow for this as well. More context: https://github.com/evcohen/eslint-plugin-jsx-a11y/issues/6
As we discussed on jsx-eslint#6, it is okay to use `alt=""` without `role="presentation"`. It is possible that we want to enforce no alt prop if `role="presentation"` but I'll leave that for another time and possibly a different rule.
As we discussed on jsx-eslint#6, it is okay to use `alt=""` without `role="presentation"`. It is possible that we want to enforce no alt prop if `role="presentation"` but I'll leave that for another time and possibly a different rule.
* Allow alt="" or role="presentation" As we discussed on #6, it is okay to use `alt=""` without `role="presentation"`. It is possible that we want to enforce no alt prop if `role="presentation"` but I'll leave that for another time and possibly a different rule. * Slightly simplify img-uses-alt error tests We don't really get much value out of having two ways to check for errors. Let's just use the one function everywhere.
This rule considers the following JSX bad:
this is also considered bad:
but this is okay:
However, I think that all three should be okay. Empty strings can be used appropriately for alt text on images that are decorative.
The text was updated successfully, but these errors were encountered: