Skip to content

Commit 3bda4f9

Browse files
author
Ethan Cohen
committed
[new] Add no-invalid-aria rule.
Based on [AX_ARIA_11](https://github.com/GoogleChrome/accessibility-developer-too ls/wiki/Audit-Rules#ax_aria_11). Ensure that any aria-* property is actually valid.
1 parent 6a374d4 commit 3bda4f9

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ module.exports = {
1111
'label-uses-for': require('./rules/label-uses-for'),
1212
'no-hash-href': require('./rules/no-hash-href'),
1313
'valid-aria-role': require('./rules/valid-aria-role'),
14-
'valid-aria-proptypes': require('./rules/valid-aria-proptypes')
14+
'valid-aria-proptypes': require('./rules/valid-aria-proptypes'),
15+
'no-invalid-aria': require('./rules/no-invalid-aria')
1516
},
1617
configs: {
1718
recommended: {
@@ -30,7 +31,8 @@ module.exports = {
3031
"jsx-a11y/label-uses-for": 2,
3132
"jsx-a11y/no-hash-href": 2,
3233
"jsx-a11y/valid-aria-role": 2,
33-
"jsx-a11y/valid-aria-proptypes": 2
34+
"jsx-a11y/valid-aria-proptypes": 2,
35+
"jsx-a11y/no-invalid-aria": 2
3436
}
3537
}
3638
}

src/rules/no-invalid-aria.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Rule Definition
99
// ----------------------------------------------------------------------------
1010

11-
import validAriaProperties from '../util/validAriaProperties';
11+
import ariaAttributes from '../util/ariaAttributes';
1212

1313
const errorMessage = name => `${name}: This attribute is an invalid ARIA attribute.`;
1414

@@ -22,7 +22,7 @@ module.exports = context => ({
2222
return;
2323
}
2424

25-
const isValid = validAriaProperties.indexOf(normalizedName) > -1;
25+
const isValid = Object.keys(ariaAttributes).indexOf(normalizedName) > -1;
2626

2727
if (isValid === false) {
2828
context.report({

src/util/validAriaProperties.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/src/rules/no-invalid-aria.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const errorMessage = name => ({
3030
type: 'JSXAttribute'
3131
});
3232

33-
import validAriaProperties from '../../../src/util/validAriaProperties';
33+
import ariaAttributes from '../../../src/util/ariaAttributes';
3434

3535
// Create basic test cases using all valid role types.
36-
const basicValidityTests = validAriaProperties.map(prop => ({
36+
const basicValidityTests = Object.keys(ariaAttributes).map(prop => ({
3737
code: `<div ${prop.toLowerCase()}="foobar" />`,
3838
parserOptions
3939
}));

0 commit comments

Comments
 (0)