diff --git a/src/rules/aria-role.js b/src/rules/aria-role.js index 83ead048d..57e4096bd 100644 --- a/src/rules/aria-role.js +++ b/src/rules/aria-role.js @@ -38,8 +38,8 @@ export default { create: (context) => { const options = context.options[0] || {}; const ignoreNonDOM = !!options.ignoreNonDOM; - const allowedInvalidRoles = new Set(options.allowedInvalidRoles || []) - const validRoles = [...roles.keys()].filter((role) => roles.get(role).abstract === false); + const allowedInvalidRoles = new Set(options.allowedInvalidRoles || []); + const validRoles = new Set([...roles.keys()].filter((role) => roles.get(role).abstract === false)); return ({ JSXAttribute: (attribute) => { @@ -64,7 +64,7 @@ export default { if (value === undefined || value === null) { return; } const values = String(value).split(' '); - const isValid = values.every((val) => allowedInvalidRoles.has(val) || validRoles.indexOf(val) > -1); + const isValid = values.every((val) => allowedInvalidRoles.has(val) || validRoles.has(val)); if (isValid === true) { return; }