@@ -18,39 +18,40 @@ import rule from '../../../src/rules/alt-text';
1818
1919const ruleTester = new RuleTester ( ) ;
2020
21- const missingPropError = ( type ) => ( {
22- message : `${ type } elements must have an alt prop, either with meaningful text, or an empty string for decorative images.` ,
21+ const missingPropError = ( nodeType ) => ( {
22+ messageId : 'img-no-alt' ,
23+ data : { nodeType } ,
2324 type : 'JSXOpeningElement' ,
2425} ) ;
2526
26- const altValueError = ( type ) => ( {
27- message : `Invalid alt value for ${ type } . \
28- Use alt="" for presentational images.` ,
27+ const altValueError = ( nodeType ) => ( {
28+ messageId : 'img-invalid- alt' ,
29+ data : { nodeType } ,
2930 type : 'JSXOpeningElement' ,
3031} ) ;
3132
3233const ariaLabelValueError = {
33- message : 'The aria-label attribute must have a value. The alt attribute is preferred over aria-label for images. ' ,
34+ messageId : 'img-no- aria-label-value ' ,
3435} ;
3536const ariaLabelledbyValueError = {
36- message : 'The aria-labelledby attribute must have a value. The alt attribute is preferred over aria-labelledby for images. ' ,
37+ messageId : 'img-no- aria-labelledby-value ' ,
3738} ;
3839
3940const preferAltError = ( ) => ( {
40- message : 'Prefer alt="" over a presentational role. First rule of aria is to not use aria if it can be achieved via native HTML. ' ,
41+ messageId : 'img-presentation- role' ,
4142 type : 'JSXOpeningElement' ,
4243} ) ;
4344
4445const objectError = {
45- message : 'Embedded < object> elements must have alternative text by providing inner text, aria-label or aria-labelledby props. ' ,
46+ messageId : 'object' ,
4647} ;
4748
4849const areaError = {
49- message : 'Each area of an image map must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop. ' ,
50+ messageId : 'area' ,
5051} ;
5152
5253const inputImageError = {
53- message : '< input> elements with type="image" must have a text alternative through the `alt`, `aria-label`, or `aria-labelledby` prop. ' ,
54+ messageId : 'input-image ' ,
5455} ;
5556
5657const componentsSettings = {
0 commit comments