/** * @fileoverview Enforce no accesskey attribute on element. * @author Ethan Cohen */ // ---------------------------------------------------------------------------- // Rule Definition // ---------------------------------------------------------------------------- import { getProp, getPropValue } from 'jsx-ast-utils'; import { generateObjSchema } from '../util/schemas'; const errorMessage = 'No access key attribute allowed. Inconsistencies ' + 'between keyboard shortcuts and keyboard comments used by screenreader ' + 'and keyboard only users create a11y complications.'; const schema = generateObjSchema(); module.exports = { meta: { docs: {}, schema: [schema], }, create: context => ({ JSXOpeningElement: (node) => { const accessKey = getProp(node.attributes, 'accesskey'); const accessKeyValue = getPropValue(accessKey); if (accessKey && accessKeyValue) { context.report({ node, message: errorMessage, }); } }, }), };