@@ -42,10 +42,10 @@ export default {
42
42
schema : [ schema ] ,
43
43
} ,
44
44
45
- create : ( context ) => {
45
+ create ( context ) {
46
46
const elementType = getElementType ( context ) ;
47
47
return {
48
- JSXOpeningElement : ( node ) => {
48
+ JSXOpeningElement ( node ) {
49
49
// If role is not explicitly defined, then try and get its implicit role.
50
50
const type = elementType ( node ) ;
51
51
const role = getProp ( node . attributes , 'role' ) ;
@@ -66,17 +66,13 @@ export default {
66
66
const {
67
67
props : propKeyValues ,
68
68
} = roles . get ( roleValue ) ;
69
- const propertySet = Object . keys ( propKeyValues ) ;
70
69
const invalidAriaPropsForRole = [ ...aria . keys ( ) ]
71
- . filter ( ( attribute ) => propertySet . indexOf ( attribute ) === - 1 ) ;
72
-
73
- node . attributes . forEach ( ( prop ) => {
74
- // Ignore the attribute if its value is null or undefined.
75
- if ( getPropValue ( prop ) == null ) return ;
76
-
77
- // Ignore the attribute if it's a spread.
78
- if ( prop . type === 'JSXSpreadAttribute' ) return ;
70
+ . filter ( ( attribute ) => ! ( attribute in propKeyValues ) ) ;
79
71
72
+ node . attributes . filter ( ( prop ) => (
73
+ getPropValue ( prop ) != null // Ignore the attribute if its value is null or undefined.
74
+ && prop . type !== 'JSXSpreadAttribute' // Ignore the attribute if it's a spread.
75
+ ) ) . forEach ( ( prop ) => {
80
76
const name = propName ( prop ) ;
81
77
if ( invalidAriaPropsForRole . indexOf ( name ) > - 1 ) {
82
78
context . report ( {
0 commit comments