Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Fixed for empty alt value in react-a11y-img-has-alt rule. #260

Conversation

t-ligu
Copy link
Contributor

@t-ligu t-ligu commented Sep 19, 2016

For img element,it must has alt attribute, empty alt must has role='presentation' and non-empty alt must has no role='presentation'.

Fixed a bug, for unit test, if using file data, the file name must has suffix '.tsx'.

@msftclas
Copy link

Hi @t-ligu, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Liubin Guo). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

Add more details in 'alt' attribute or use role='presentation' for presentational images. \
export function getFailureStringEmptyAltAndNotPresentationRole(tagName: string): string {
return `The value of alt attribute in <${tagName}> tag is empty and role value is not presentation. \
Add more details in alt attribute or use empty alt attribute and role='presentation' for presentational images. \
Copy link
Collaborator

@ipip2005 ipip2005 Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more details in alt attribute or use empty alt attribute and role='presentation' for presentational images. better be
Specify role attribute to equal 'presentation' when 'alt' attribute is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.


export function getFailureStringNonEmptyAltAndPresentationRole(tagName: string): string {
return `The value of alt attribute in <${tagName}> tag is non-empty and role value is presentation. \
Remove role='presentation' or use empty alt attribute and role='presentation' for presentational images. \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove role='presentation' or use empty alt attribute and role='presentation' for presentational images.
better be
`Specify 'alt' attributeto be empty when role attributes equals 'presentation'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

@@ -31,7 +38,8 @@ export class Rule extends Lint.Rules.AbstractRule {
public static metadata: ExtendedMetadata = {
ruleName: 'react-a11y-img-has-alt',
type: 'maintainability',
description: 'Enforce that an `img` element contains the `alt` attribute or `role="presentation"` for decorative image.',
description: 'Enforce that an `img` element contains the non-empty `alt` attribute or' +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is confusing, A or B and C is not easy to understand. Better be:
'Enforce that an img element contains the non-empty alt attribute. For decorative images, using empty alt attribute and role="presentation".`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

Copy link
Collaborator

@ipip2005 ipip2005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments

@HamletDRC HamletDRC closed this in e690958 Sep 20, 2016
@HamletDRC HamletDRC modified the milestone: None Oct 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants