Permalink
Cannot retrieve contributors at this time
49 lines (42 sloc)
1.44 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/scope-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 scope prop is only used on <th> elements. | |
* @author Ethan Cohen | |
*/ | |
// ----------------------------------------------------------------------------- | |
// Requirements | |
// ----------------------------------------------------------------------------- | |
import { RuleTester } from 'eslint'; | |
import parserOptionsMapper from '../../__util__/parserOptionsMapper'; | |
import rule from '../../../src/rules/scope'; | |
// ----------------------------------------------------------------------------- | |
// Tests | |
// ----------------------------------------------------------------------------- | |
const ruleTester = new RuleTester(); | |
const expectedError = { | |
message: 'The scope prop can only be used on <th> elements.', | |
type: 'JSXAttribute', | |
}; | |
const componentsSettings = { | |
'jsx-a11y': { | |
components: { | |
Foo: 'div', | |
TableHeader: 'th', | |
}, | |
}, | |
}; | |
ruleTester.run('scope', rule, { | |
valid: [ | |
{ code: '<div />;' }, | |
{ code: '<div foo />;' }, | |
{ code: '<th scope />' }, | |
{ code: '<th scope="row" />' }, | |
{ code: '<th scope={foo} />' }, | |
{ code: '<th scope={"col"} {...props} />' }, | |
{ code: '<Foo scope="bar" {...props} />' }, | |
{ code: '<TableHeader scope="row" />', settings: componentsSettings }, | |
].map(parserOptionsMapper), | |
invalid: [ | |
{ code: '<div scope />', errors: [expectedError] }, | |
{ code: '<Foo scope="bar" />', settings: componentsSettings, errors: [expectedError] }, | |
].map(parserOptionsMapper), | |
}); |