Skip to content

Commit 02a438d

Browse files
Ethan Cohenbeefancohen
authored andcommitted
Ignore custom components for role-has-required-aria-props.
1 parent 339d23a commit 02a438d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const basicValidityTests = [...roles.keys()].map((role) => {
4747
ruleTester.run('role-has-required-aria-props', rule, {
4848
valid: [
4949
{ code: '<Bar baz />' },
50+
{ code: '<MyComponent role="combobox" />' },
5051
// Variables should pass, as we are only testing literals.
5152
{ code: '<div />' },
5253
{ code: '<div></div>' },

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

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

11-
import { roles } from 'aria-query';
12-
import { getProp, getLiteralPropValue, propName } from 'jsx-ast-utils';
11+
import { dom, roles } from 'aria-query';
12+
import { elementType, getProp, getLiteralPropValue, propName } from 'jsx-ast-utils';
1313
import { generateObjSchema } from '../util/schemas';
1414

1515
const errorMessage = (role, requiredProps) =>
@@ -32,6 +32,11 @@ module.exports = {
3232
return;
3333
}
3434

35+
const type = elementType(attribute.parent);
36+
if (!dom.get(type)) {
37+
return;
38+
}
39+
3540
const value = getLiteralPropValue(attribute);
3641

3742
// If value is undefined, then the role attribute will be dropped in the DOM.

0 commit comments

Comments
 (0)