Permalink
Cannot retrieve contributors at this time
47 lines (41 sloc)
1.9 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint-plugin-jsx-a11y/__tests__/src/rules/no-access-key-test.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileoverview Enforce no accesskey attribute on element. | |
* @author Ethan Cohen | |
*/ | |
// ----------------------------------------------------------------------------- | |
// Requirements | |
// ----------------------------------------------------------------------------- | |
import { RuleTester } from 'eslint'; | |
import parserOptionsMapper from '../../__util__/parserOptionsMapper'; | |
import rule from '../../../src/rules/no-access-key'; | |
// ----------------------------------------------------------------------------- | |
// Tests | |
// ----------------------------------------------------------------------------- | |
const ruleTester = new RuleTester(); | |
const expectedError = { | |
message: 'No access key attribute allowed. Inconsistencies between keyboard shortcuts and keyboard commands used by screenreaders and keyboard-only users create a11y complications.', | |
type: 'JSXOpeningElement', | |
}; | |
ruleTester.run('no-access-key', rule, { | |
valid: [ | |
{ code: '<div />;' }, | |
{ code: '<div {...props} />' }, | |
{ code: '<div accessKey={undefined} />' }, | |
].map(parserOptionsMapper), | |
invalid: [ | |
{ code: '<div accesskey="h" />', errors: [expectedError] }, | |
{ code: '<div accessKey="h" />', errors: [expectedError] }, | |
{ code: '<div accessKey="h" {...props} />', errors: [expectedError] }, | |
{ code: '<div acCesSKeY="y" />', errors: [expectedError] }, | |
{ code: '<div accessKey={"y"} />', errors: [expectedError] }, | |
{ code: '<div accessKey={`${y}`} />', errors: [expectedError] }, | |
{ | |
code: '<div accessKey={`${undefined}y${undefined}`} />', | |
errors: [expectedError], | |
}, | |
{ code: '<div accessKey={`This is ${bad}`} />', errors: [expectedError] }, | |
{ code: '<div accessKey={accessKey} />', errors: [expectedError] }, | |
{ code: '<div accessKey={`${undefined}`} />', errors: [expectedError] }, | |
{ code: '<div accessKey={`${undefined}${undefined}`} />', errors: [expectedError] }, | |
].map(parserOptionsMapper), | |
}); |