UNPKG

@jsxtools/eslint-plugin-jsx-a11y

Version:

Static AST checker for accessibility rules on JSX elements for flat ESLint Config.

18 lines (15 loc) 492 B
const ariaQuery = require('aria-query'); const jsxAstUtils = require('./module/jsx-ast-utils.cjs'); function getExplicitRole(tag, attributes) { const explicitRole = function toLowerCase(role) { if (typeof role === "string") { return role.toLowerCase(); } return null; }(jsxAstUtils.getLiteralPropValue(jsxAstUtils.getProp(attributes, "role"))); if (ariaQuery.roles.has(explicitRole)) { return explicitRole; } return null; } module.exports = getExplicitRole;