Permalink
Cannot retrieve contributors at this time
50 lines (43 sloc)
1.69 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-distracting-elements-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 distracting elements are not used. | |
* @author Ethan Cohen | |
*/ | |
// ----------------------------------------------------------------------------- | |
// Requirements | |
// ----------------------------------------------------------------------------- | |
import { RuleTester } from 'eslint'; | |
import parserOptionsMapper from '../../__util__/parserOptionsMapper'; | |
import rule from '../../../src/rules/no-distracting-elements'; | |
// ----------------------------------------------------------------------------- | |
// Tests | |
// ----------------------------------------------------------------------------- | |
const ruleTester = new RuleTester(); | |
const expectedError = (element) => ({ | |
message: `Do not use <${element}> elements as they can create visual accessibility issues and are deprecated.`, | |
type: 'JSXOpeningElement', | |
}); | |
const componentsSettings = { | |
'jsx-a11y': { | |
components: { | |
Blink: 'blink', | |
}, | |
}, | |
}; | |
ruleTester.run('no-marquee', rule, { | |
valid: [ | |
{ code: '<div />;' }, | |
{ code: '<Marquee />' }, | |
{ code: '<div marquee />' }, | |
{ code: '<Blink />' }, | |
{ code: '<div blink />' }, | |
].map(parserOptionsMapper), | |
invalid: [ | |
{ code: '<marquee />', errors: [expectedError('marquee')] }, | |
{ code: '<marquee {...props} />', errors: [expectedError('marquee')] }, | |
{ code: '<marquee lang={undefined} />', errors: [expectedError('marquee')] }, | |
{ code: '<blink />', errors: [expectedError('blink')] }, | |
{ code: '<blink {...props} />', errors: [expectedError('blink')] }, | |
{ code: '<blink foo={undefined} />', errors: [expectedError('blink')] }, | |
{ code: '<Blink />', settings: componentsSettings, errors: [expectedError('blink')] }, | |
].map(parserOptionsMapper), | |
}); |