|
| 1 | +import { RuleTester } from 'eslint'; |
| 2 | +import { noIdrefAriaAttribute } from './no-idref-aria-attribute'; |
| 3 | +import { convertAnnotatedSourceToFailureCase } from '../utils/testing'; |
| 4 | + |
| 5 | +const ruleTester = new RuleTester({ |
| 6 | + parser: require.resolve('vue-eslint-parser'), |
| 7 | + parserOptions: { |
| 8 | + sourceType: 'module', |
| 9 | + }, |
| 10 | +}); |
| 11 | + |
| 12 | +ruleTester.run('no-idref-aria-attribute', noIdrefAriaAttribute, { |
| 13 | + valid: [ |
| 14 | + { |
| 15 | + code: '<template><VBreadcrumb aria-label="breadcrumb"></VBreadcrumb></template>', |
| 16 | + }, |
| 17 | + { |
| 18 | + code: '<template><VButton aria-label="button"></VButton></template>', |
| 19 | + }, |
| 20 | + { |
| 21 | + code: '<template><VNav aria-label="navigation"></VNav></template>', |
| 22 | + }, |
| 23 | + { |
| 24 | + code: '<template><VTagGroup aria-label="tags"></VTagGroup></template>', |
| 25 | + }, |
| 26 | + { |
| 27 | + code: '<template><VTag aria-label="tag"></VTag></template>', |
| 28 | + }, |
| 29 | + { |
| 30 | + code: '<template><VActionGroup aria-label="actions"></VActionGroup></template>', |
| 31 | + }, |
| 32 | + { |
| 33 | + code: '<template><VHeader aria-label="header"></VHeader></template>', |
| 34 | + }, |
| 35 | + { |
| 36 | + code: '<template><VSwitch aria-label="switch"></VSwitch></template>', |
| 37 | + }, |
| 38 | + { |
| 39 | + code: '<template><VDivider aria-label="divider"></VDivider></template>', |
| 40 | + }, |
| 41 | + { |
| 42 | + code: '<template><VTextArea aria-label="textarea"></VTextArea></template>', |
| 43 | + }, |
| 44 | + { |
| 45 | + code: '<template><VCheckbox aria-label="checkbox"></VCheckbox></template>', |
| 46 | + }, |
| 47 | + { |
| 48 | + code: '<template><VSearchableSelect aria-label="select"></VSearchableSelect></template>', |
| 49 | + }, |
| 50 | + { |
| 51 | + code: '<template><VFilePicker aria-label="file picker"></VFilePicker></template>', |
| 52 | + }, |
| 53 | + { |
| 54 | + code: '<template><VCalendarEvent aria-label="event"></VCalendarEvent></template>', |
| 55 | + }, |
| 56 | + { |
| 57 | + code: '<template><VProgress aria-label="progress"></VProgress></template>', |
| 58 | + }, |
| 59 | + { |
| 60 | + code: '<template><VProgressRing aria-label="progress"></VProgressRing></template>', |
| 61 | + }, |
| 62 | + { |
| 63 | + code: '<template><VSelectableBox aria-label="box"></VSelectableBox></template>', |
| 64 | + }, |
| 65 | + { |
| 66 | + code: '<template><VBanner aria-label="banner"></VBanner></template>', |
| 67 | + }, |
| 68 | + { |
| 69 | + code: '<template><VMenu aria-label="menu"></VMenu></template>', |
| 70 | + }, |
| 71 | + { |
| 72 | + code: '<template><VTextField aria-label="text field"></VTextField></template>', |
| 73 | + }, |
| 74 | + { |
| 75 | + code: '<template><VDialog aria-label="dialog"></VDialog></template>', |
| 76 | + }, |
| 77 | + { |
| 78 | + code: '<template><VSlider aria-label="slider"></VSlider></template>', |
| 79 | + }, |
| 80 | + { |
| 81 | + code: '<template><VTextAnchor aria-label="anchor"></VTextAnchor></template>', |
| 82 | + }, |
| 83 | + { |
| 84 | + code: '<template><VSplitButton aria-label="split button"></VSplitButton></template>', |
| 85 | + }, |
| 86 | + { |
| 87 | + code: '<template><VNumberField aria-label="number field"></VNumberField></template>', |
| 88 | + }, |
| 89 | + { |
| 90 | + code: '<template><VNavDisclosure aria-label="disclosure"></VNavDisclosure></template>', |
| 91 | + }, |
| 92 | + ], |
| 93 | + invalid: [ |
| 94 | + convertAnnotatedSourceToFailureCase({ |
| 95 | + annotatedSource: ` |
| 96 | + <template><VMenu aria-controls="id"></VMenu></template> |
| 97 | + ~~~~~~~~~~~~~ |
| 98 | + `, |
| 99 | + message: |
| 100 | + 'IDREF ARIA attributes (like aria-controls) should not be used on components that delegate ARIA attributes, as they will not work correctly with shadow DOM.', |
| 101 | + }), |
| 102 | + convertAnnotatedSourceToFailureCase({ |
| 103 | + annotatedSource: ` |
| 104 | + <template><VButton aria-labelledby="id"></VButton></template> |
| 105 | + ~~~~~~~~~~~~~~~ |
| 106 | + `, |
| 107 | + message: |
| 108 | + 'IDREF ARIA attributes (like aria-labelledby) should not be used on components that delegate ARIA attributes, as they will not work correctly with shadow DOM.', |
| 109 | + }), |
| 110 | + convertAnnotatedSourceToFailureCase({ |
| 111 | + annotatedSource: ` |
| 112 | + <template><VTextField aria-owns="id"></VTextField></template> |
| 113 | + ~~~~~~~~~ |
| 114 | + `, |
| 115 | + message: |
| 116 | + 'IDREF ARIA attributes (like aria-owns) should not be used on components that delegate ARIA attributes, as they will not work correctly with shadow DOM.', |
| 117 | + }), |
| 118 | + convertAnnotatedSourceToFailureCase({ |
| 119 | + annotatedSource: ` |
| 120 | + <template><VDialog aria-details="id"></VDialog></template> |
| 121 | + ~~~~~~~~~~~~ |
| 122 | + `, |
| 123 | + message: |
| 124 | + 'IDREF ARIA attributes (like aria-details) should not be used on components that delegate ARIA attributes, as they will not work correctly with shadow DOM.', |
| 125 | + }), |
| 126 | + convertAnnotatedSourceToFailureCase({ |
| 127 | + annotatedSource: ` |
| 128 | + <template><VMenu aria-errormessage="id"></VMenu></template> |
| 129 | + ~~~~~~~~~~~~~~~~~ |
| 130 | + `, |
| 131 | + message: |
| 132 | + 'IDREF ARIA attributes (like aria-errormessage) should not be used on components that delegate ARIA attributes, as they will not work correctly with shadow DOM.', |
| 133 | + }), |
| 134 | + convertAnnotatedSourceToFailureCase({ |
| 135 | + annotatedSource: ` |
| 136 | + <template><VButton aria-flowto="id"></VButton></template> |
| 137 | + ~~~~~~~~~~~ |
| 138 | + `, |
| 139 | + message: |
| 140 | + 'IDREF ARIA attributes (like aria-flowto) should not be used on components that delegate ARIA attributes, as they will not work correctly with shadow DOM.', |
| 141 | + }), |
| 142 | + ], |
| 143 | +}); |
0 commit comments