Skip to content

Commit e215b87

Browse files
authored
Merge pull request #696 from jsx-eslint/fix-aria-1-2-test-failures
Update to ARIA 1.2; fix test failures
2 parents 4c60546 + cce838a commit e215b87

5 files changed

+151
-68
lines changed

__tests__/src/rules/control-has-associated-label-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ const alwaysValid = [
192192
{ code: '<div role="presentation" />' },
193193
{ code: '<div role="region" />' },
194194
{ code: '<div role="rowgroup" />' },
195-
{ code: '<div role="scrollbar" />' },
196195
{ code: '<div role="search" />' },
197196
{ code: '<div role="separator" />' },
198197
{ code: '<div role="status" />' },
@@ -271,6 +270,7 @@ const neverValid = [
271270
{ code: '<div role="progressbar" />', errors: [expectedError] },
272271
{ code: '<div role="radio" />', errors: [expectedError] },
273272
{ code: '<div role="rowheader" />', errors: [expectedError] },
273+
{ code: '<div role="scrollbar" />', errors: [expectedError] },
274274
{ code: '<div role="searchbox" />', errors: [expectedError] },
275275
{ code: '<div role="slider" />', errors: [expectedError] },
276276
{ code: '<div role="spinbutton" />', errors: [expectedError] },

__tests__/src/rules/no-noninteractive-element-interactions-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ const alwaysValid = [
184184
{ code: '<div role="radiogroup" onClick={() => {}} />;' },
185185
{ code: '<div role="row" onClick={() => {}} />;' },
186186
{ code: '<div role="rowheader" onClick={() => {}} />;' },
187+
{ code: '<div role="scrollbar" onClick={() => {}} />;' },
187188
{ code: '<div role="searchbox" onClick={() => {}} />;' },
188189
{ code: '<div role="slider" onClick={() => {}} />;' },
189190
{ code: '<div role="spinbutton" onClick={() => {}} />;' },
@@ -340,7 +341,6 @@ const neverValid = [
340341
{ code: '<div role="rowgroup" onClick={() => {}} />;', errors: [expectedError] },
341342
{ code: '<div role="search" onClick={() => {}} />;', errors: [expectedError] },
342343
{ code: '<div role="separator" onClick={() => {}} />;', errors: [expectedError] },
343-
{ code: '<div role="scrollbar" onClick={() => {}} />;', errors: [expectedError] },
344344
{ code: '<div role="status" onClick={() => {}} />;', errors: [expectedError] },
345345
{ code: '<div role="table" onClick={() => {}} />;', errors: [expectedError] },
346346
{ code: '<div role="tabpanel" onClick={() => {}} />;', errors: [expectedError] },

__tests__/src/rules/role-has-required-aria-props-test.js

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,6 @@ ruleTester.run('role-has-required-aria-props', rule, {
6969
code: '<div role="slider" aria-valuemax aria-valuemin />',
7070
errors: [errorMessage('slider')],
7171
},
72-
{
73-
code: '<div role="slider" aria-valuemax aria-valuenow />',
74-
errors: [errorMessage('slider')],
75-
},
76-
{
77-
code: '<div role="slider" aria-valuemin aria-valuenow />',
78-
errors: [errorMessage('slider')],
79-
},
80-
81-
// SPINBUTTON
82-
{ code: '<div role="spinbutton" />', errors: [errorMessage('spinbutton')] },
83-
{
84-
code: '<div role="spinbutton" aria-valuemax />',
85-
errors: [errorMessage('spinbutton')],
86-
},
87-
{
88-
code: '<div role="spinbutton" aria-valuemax aria-valuemin />',
89-
errors: [errorMessage('spinbutton')],
90-
},
91-
{
92-
code: '<div role="spinbutton" aria-valuemax aria-valuenow />',
93-
errors: [errorMessage('spinbutton')],
94-
},
95-
{
96-
code: '<div role="spinbutton" aria-valuemin aria-valuenow />',
97-
errors: [errorMessage('spinbutton')],
98-
},
9972

10073
// CHECKBOX
10174
{ code: '<div role="checkbox" />', errors: [errorMessage('checkbox')] },
@@ -135,5 +108,13 @@ ruleTester.run('role-has-required-aria-props', rule, {
135108
code: '<div role="scrollbar" aria-valuemin aria-valuenow />',
136109
errors: [errorMessage('scrollbar')],
137110
},
111+
{
112+
code: '<div role="heading" />',
113+
errors: [errorMessage('heading')],
114+
},
115+
{
116+
code: '<div role="option" />',
117+
errors: [errorMessage('option')],
118+
},
138119
].map(parserOptionsMapper),
139120
});

__tests__/src/rules/role-supports-aria-props-test.js

Lines changed: 140 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ ruleTester.run('role-supports-aria-props', rule, {
8585
{ code: '<a href="#" aria-dropeffect />' },
8686
{ code: '<a href="#" aria-flowto />' },
8787
{ code: '<a href="#" aria-grabbed />' },
88-
{ code: '<a href="#" aria-haspopup />' },
8988
{ code: '<a href="#" aria-hidden />' },
90-
{ code: '<a href="#" aria-invalid />' },
9189
{ code: '<a href="#" aria-label />' },
9290
{ code: '<a href="#" aria-labelledby />' },
9391
{ code: '<a href="#" aria-live />' },
@@ -107,9 +105,7 @@ ruleTester.run('role-supports-aria-props', rule, {
107105
{ code: '<area href="#" aria-dropeffect />' },
108106
{ code: '<area href="#" aria-flowto />' },
109107
{ code: '<area href="#" aria-grabbed />' },
110-
{ code: '<area href="#" aria-haspopup />' },
111108
{ code: '<area href="#" aria-hidden />' },
112-
{ code: '<area href="#" aria-invalid />' },
113109
{ code: '<area href="#" aria-label />' },
114110
{ code: '<area href="#" aria-labelledby />' },
115111
{ code: '<area href="#" aria-live />' },
@@ -129,9 +125,7 @@ ruleTester.run('role-supports-aria-props', rule, {
129125
{ code: '<link href="#" aria-dropeffect />' },
130126
{ code: '<link href="#" aria-flowto />' },
131127
{ code: '<link href="#" aria-grabbed />' },
132-
{ code: '<link href="#" aria-haspopup />' },
133128
{ code: '<link href="#" aria-hidden />' },
134-
{ code: '<link href="#" aria-invalid />' },
135129
{ code: '<link href="#" aria-label />' },
136130
{ code: '<link href="#" aria-labelledby />' },
137131
{ code: '<link href="#" aria-live />' },
@@ -149,7 +143,6 @@ ruleTester.run('role-supports-aria-props', rule, {
149143

150144
// MENU TESTS - implicit role is `toolbar` when `type="toolbar"`
151145
{ code: '<menu type="toolbar" aria-activedescendant />' },
152-
{ code: '<menu type="toolbar" aria-expanded />' },
153146
{ code: '<menu type="toolbar" aria-atomic />' },
154147
{ code: '<menu type="toolbar" aria-busy />' },
155148
{ code: '<menu type="toolbar" aria-controls />' },
@@ -158,9 +151,7 @@ ruleTester.run('role-supports-aria-props', rule, {
158151
{ code: '<menu type="toolbar" aria-dropeffect />' },
159152
{ code: '<menu type="toolbar" aria-flowto />' },
160153
{ code: '<menu type="toolbar" aria-grabbed />' },
161-
{ code: '<menu type="toolbar" aria-haspopup />' },
162154
{ code: '<menu type="toolbar" aria-hidden />' },
163-
{ code: '<menu type="toolbar" aria-invalid />' },
164155
{ code: '<menu type="toolbar" aria-label />' },
165156
{ code: '<menu type="toolbar" aria-labelledby />' },
166157
{ code: '<menu type="toolbar" aria-live />' },
@@ -182,7 +173,6 @@ ruleTester.run('role-supports-aria-props', rule, {
182173
{ code: '<menuitem type="command" aria-grabbed />' },
183174
{ code: '<menuitem type="command" aria-haspopup />' },
184175
{ code: '<menuitem type="command" aria-hidden />' },
185-
{ code: '<menuitem type="command" aria-invalid />' },
186176
{ code: '<menuitem type="command" aria-label />' },
187177
{ code: '<menuitem type="command" aria-labelledby />' },
188178
{ code: '<menuitem type="command" aria-live />' },
@@ -225,7 +215,6 @@ ruleTester.run('role-supports-aria-props', rule, {
225215
{ code: '<menuitem type="radio" aria-owns />' },
226216
{ code: '<menuitem type="radio" aria-relevant />' },
227217
{ code: '<menuitem type="radio" aria-posinset />' },
228-
{ code: '<menuitem type="radio" aria-selected />' },
229218
{ code: '<menuitem type="radio" aria-setsize />' },
230219

231220
// these will have global
@@ -246,7 +235,6 @@ ruleTester.run('role-supports-aria-props', rule, {
246235
{ code: '<input type="button" aria-grabbed />' },
247236
{ code: '<input type="button" aria-haspopup />' },
248237
{ code: '<input type="button" aria-hidden />' },
249-
{ code: '<input type="button" aria-invalid />' },
250238
{ code: '<input type="button" aria-label />' },
251239
{ code: '<input type="button" aria-labelledby />' },
252240
{ code: '<input type="button" aria-live />' },
@@ -265,7 +253,6 @@ ruleTester.run('role-supports-aria-props', rule, {
265253
{ code: '<input type="image" aria-grabbed />' },
266254
{ code: '<input type="image" aria-haspopup />' },
267255
{ code: '<input type="image" aria-hidden />' },
268-
{ code: '<input type="image" aria-invalid />' },
269256
{ code: '<input type="image" aria-label />' },
270257
{ code: '<input type="image" aria-labelledby />' },
271258
{ code: '<input type="image" aria-live />' },
@@ -284,7 +271,6 @@ ruleTester.run('role-supports-aria-props', rule, {
284271
{ code: '<input type="reset" aria-grabbed />' },
285272
{ code: '<input type="reset" aria-haspopup />' },
286273
{ code: '<input type="reset" aria-hidden />' },
287-
{ code: '<input type="reset" aria-invalid />' },
288274
{ code: '<input type="reset" aria-label />' },
289275
{ code: '<input type="reset" aria-labelledby />' },
290276
{ code: '<input type="reset" aria-live />' },
@@ -303,23 +289,21 @@ ruleTester.run('role-supports-aria-props', rule, {
303289
{ code: '<input type="submit" aria-grabbed />' },
304290
{ code: '<input type="submit" aria-haspopup />' },
305291
{ code: '<input type="submit" aria-hidden />' },
306-
{ code: '<input type="submit" aria-invalid />' },
307292
{ code: '<input type="submit" aria-label />' },
308293
{ code: '<input type="submit" aria-labelledby />' },
309294
{ code: '<input type="submit" aria-live />' },
310295
{ code: '<input type="submit" aria-owns />' },
311296
{ code: '<input type="submit" aria-relevant />' },
312297
// when `type="checkbox"`, the implicit role is `checkbox`
313-
{ code: '<input type="checkbox" aria-checked />' },
314298
{ code: '<input type="checkbox" aria-atomic />' },
315299
{ code: '<input type="checkbox" aria-busy />' },
300+
{ code: '<input type="checkbox" aria-checked />' },
316301
{ code: '<input type="checkbox" aria-controls />' },
317302
{ code: '<input type="checkbox" aria-describedby />' },
318303
{ code: '<input type="checkbox" aria-disabled />' },
319304
{ code: '<input type="checkbox" aria-dropeffect />' },
320305
{ code: '<input type="checkbox" aria-flowto />' },
321306
{ code: '<input type="checkbox" aria-grabbed />' },
322-
{ code: '<input type="checkbox" aria-haspopup />' },
323307
{ code: '<input type="checkbox" aria-hidden />' },
324308
{ code: '<input type="checkbox" aria-invalid />' },
325309
{ code: '<input type="checkbox" aria-label />' },
@@ -328,25 +312,22 @@ ruleTester.run('role-supports-aria-props', rule, {
328312
{ code: '<input type="checkbox" aria-owns />' },
329313
{ code: '<input type="checkbox" aria-relevant />' },
330314
// when `type="radio"`, the implicit role is `radio`
331-
{ code: '<input type="radio" aria-checked />' },
332315
{ code: '<input type="radio" aria-atomic />' },
333316
{ code: '<input type="radio" aria-busy />' },
317+
{ code: '<input type="radio" aria-checked />' },
334318
{ code: '<input type="radio" aria-controls />' },
335319
{ code: '<input type="radio" aria-describedby />' },
336320
{ code: '<input type="radio" aria-disabled />' },
337321
{ code: '<input type="radio" aria-dropeffect />' },
338322
{ code: '<input type="radio" aria-flowto />' },
339323
{ code: '<input type="radio" aria-grabbed />' },
340-
{ code: '<input type="radio" aria-haspopup />' },
341324
{ code: '<input type="radio" aria-hidden />' },
342-
{ code: '<input type="radio" aria-invalid />' },
343325
{ code: '<input type="radio" aria-label />' },
344326
{ code: '<input type="radio" aria-labelledby />' },
345327
{ code: '<input type="radio" aria-live />' },
346328
{ code: '<input type="radio" aria-owns />' },
347329
{ code: '<input type="radio" aria-relevant />' },
348330
{ code: '<input type="radio" aria-posinset />' },
349-
{ code: '<input type="radio" aria-selected />' },
350331
{ code: '<input type="radio" aria-setsize />' },
351332
// when `type="range"`, the implicit role is `slider`
352333
{ code: '<input type="range" aria-valuemax />' },
@@ -384,14 +365,7 @@ ruleTester.run('role-supports-aria-props', rule, {
384365
{ code: '<h2 role="presentation" aria-level={undefined} />' },
385366

386367
// OTHER TESTS
387-
{ code: '<aside aria-expanded />' },
388-
{ code: '<article aria-expanded />' },
389-
{ code: '<body aria-expanded />' },
390368
{ code: '<button aria-pressed />' },
391-
{ code: '<datalist aria-expanded />' },
392-
{ code: '<details aria-expanded />' },
393-
{ code: '<dialog aria-expanded />' },
394-
{ code: '<dl aria-expanded />' },
395369
{ code: '<form aria-hidden />' },
396370
{ code: '<h1 aria-hidden />' },
397371
{ code: '<h2 aria-hidden />' },
@@ -401,20 +375,12 @@ ruleTester.run('role-supports-aria-props', rule, {
401375
{ code: '<h6 aria-hidden />' },
402376
{ code: '<hr aria-hidden />' },
403377
{ code: '<li aria-current />' },
404-
{ code: '<li aria-expanded />' },
405378
{ code: '<meter aria-atomic />' },
406-
{ code: '<nav aria-expanded />' },
407-
{ code: '<ol aria-expanded />' },
408379
{ code: '<option aria-atomic />' },
409-
{ code: '<output aria-expanded />' },
410380
{ code: '<progress aria-atomic />' },
411-
{ code: '<section aria-expanded />' },
412-
{ code: '<select aria-expanded />' },
413-
{ code: '<tbody aria-expanded />' },
414381
{ code: '<textarea aria-hidden />' },
415-
{ code: '<tfoot aria-expanded />' },
416-
{ code: '<thead aria-expanded />' },
417-
{ code: '<ul aria-expanded />' },
382+
{ code: '<select aria-expanded />' },
383+
{ code: '<datalist aria-expanded />' },
418384

419385
].concat(validTests).map(parserOptionsMapper),
420386

@@ -444,5 +410,141 @@ ruleTester.run('role-supports-aria-props', rule, {
444410
code: '<aside aria-checked />',
445411
errors: [errorMessage('aria-checked', 'complementary', 'aside', true)],
446412
},
413+
{
414+
code: '<ul aria-expanded />',
415+
errors: [errorMessage('aria-expanded', 'list', 'ul', true)],
416+
},
417+
{
418+
code: '<details aria-expanded />',
419+
errors: [errorMessage('aria-expanded', 'group', 'details', true)],
420+
},
421+
{
422+
code: '<dialog aria-expanded />',
423+
errors: [errorMessage('aria-expanded', 'dialog', 'dialog', true)],
424+
},
425+
{
426+
code: '<dl aria-expanded />',
427+
errors: [errorMessage('aria-expanded', 'list', 'dl', true)],
428+
},
429+
{
430+
code: '<aside aria-expanded />',
431+
errors: [errorMessage('aria-expanded', 'complementary', 'aside', true)],
432+
},
433+
{
434+
code: '<article aria-expanded />',
435+
errors: [errorMessage('aria-expanded', 'article', 'article', true)],
436+
},
437+
{
438+
code: '<body aria-expanded />',
439+
errors: [errorMessage('aria-expanded', 'document', 'body', true)],
440+
},
441+
{
442+
code: '<li aria-expanded />',
443+
errors: [errorMessage('aria-expanded', 'listitem', 'li', true)],
444+
},
445+
{
446+
code: '<nav aria-expanded />',
447+
errors: [errorMessage('aria-expanded', 'navigation', 'nav', true)],
448+
},
449+
{
450+
code: '<ol aria-expanded />',
451+
errors: [errorMessage('aria-expanded', 'list', 'ol', true)],
452+
},
453+
{
454+
code: '<output aria-expanded />',
455+
errors: [errorMessage('aria-expanded', 'status', 'output', true)],
456+
},
457+
{
458+
code: '<section aria-expanded />',
459+
errors: [errorMessage('aria-expanded', 'region', 'section', true)],
460+
},
461+
{
462+
code: '<tbody aria-expanded />',
463+
errors: [errorMessage('aria-expanded', 'rowgroup', 'tbody', true)],
464+
},
465+
{
466+
code: '<tfoot aria-expanded />',
467+
errors: [errorMessage('aria-expanded', 'rowgroup', 'tfoot', true)],
468+
},
469+
{
470+
code: '<thead aria-expanded />',
471+
errors: [errorMessage('aria-expanded', 'rowgroup', 'thead', true)],
472+
},
473+
{
474+
code: '<input type="radio" aria-invalid />',
475+
errors: [errorMessage('aria-invalid', 'radio', 'input', true)],
476+
},
477+
{
478+
code: '<input type="radio" aria-selected />',
479+
errors: [errorMessage('aria-selected', 'radio', 'input', true)],
480+
},
481+
{
482+
code: '<input type="radio" aria-haspopup />',
483+
errors: [errorMessage('aria-haspopup', 'radio', 'input', true)],
484+
},
485+
{
486+
code: '<input type="checkbox" aria-haspopup />',
487+
errors: [errorMessage('aria-haspopup', 'checkbox', 'input', true)],
488+
},
489+
{
490+
code: '<input type="reset" aria-invalid />',
491+
errors: [errorMessage('aria-invalid', 'button', 'input', true)],
492+
},
493+
{
494+
code: '<input type="submit" aria-invalid />',
495+
errors: [errorMessage('aria-invalid', 'button', 'input', true)],
496+
},
497+
{
498+
code: '<input type="image" aria-invalid />',
499+
errors: [errorMessage('aria-invalid', 'button', 'input', true)],
500+
},
501+
{
502+
code: '<input type="button" aria-invalid />',
503+
errors: [errorMessage('aria-invalid', 'button', 'input', true)],
504+
},
505+
{
506+
code: '<menuitem type="command" aria-invalid />',
507+
errors: [errorMessage('aria-invalid', 'menuitem', 'menuitem', true)],
508+
},
509+
{
510+
code: '<menuitem type="radio" aria-selected />',
511+
errors: [errorMessage('aria-selected', 'menuitemradio', 'menuitem', true)],
512+
},
513+
{
514+
code: '<menu type="toolbar" aria-haspopup />',
515+
errors: [errorMessage('aria-haspopup', 'toolbar', 'menu', true)],
516+
},
517+
{
518+
code: '<menu type="toolbar" aria-invalid />',
519+
errors: [errorMessage('aria-invalid', 'toolbar', 'menu', true)],
520+
},
521+
{
522+
code: '<menu type="toolbar" aria-expanded />',
523+
errors: [errorMessage('aria-expanded', 'toolbar', 'menu', true)],
524+
},
525+
{
526+
code: '<link href="#" aria-invalid />',
527+
errors: [errorMessage('aria-invalid', 'link', 'link', true)],
528+
},
529+
{
530+
code: '<link href="#" aria-haspopup />',
531+
errors: [errorMessage('aria-haspopup', 'link', 'link', true)],
532+
},
533+
{
534+
code: '<area href="#" aria-invalid />',
535+
errors: [errorMessage('aria-invalid', 'link', 'area', true)],
536+
},
537+
{
538+
code: '<area href="#" aria-haspopup />',
539+
errors: [errorMessage('aria-haspopup', 'link', 'area', true)],
540+
},
541+
{
542+
code: '<a href="#" aria-haspopup />',
543+
errors: [errorMessage('aria-haspopup', 'link', 'a', true)],
544+
},
545+
{
546+
code: '<a href="#" aria-invalid />',
547+
errors: [errorMessage('aria-invalid', 'link', 'a', true)],
548+
},
447549
].concat(invalidTests).map(parserOptionsMapper),
448550
});

0 commit comments

Comments
 (0)