-
Notifications
You must be signed in to change notification settings - Fork 199
Fixed for empty alt value in react-a11y-img-has-alt rule. #260
Fixed for empty alt value in react-a11y-img-has-alt rule. #260
Conversation
Hi @t-ligu, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
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. \ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. \ |
There was a problem hiding this comment.
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'.
There was a problem hiding this comment.
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' + |
There was a problem hiding this comment.
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"
.`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left comments
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'.