Permalink
Cannot retrieve contributors at this time
55 lines (48 sloc)
1.73 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/lang-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 lang attribute has a valid value. | |
* @author Ethan Cohen | |
*/ | |
// ----------------------------------------------------------------------------- | |
// Requirements | |
// ----------------------------------------------------------------------------- | |
import { RuleTester } from 'eslint'; | |
import parserOptionsMapper from '../../__util__/parserOptionsMapper'; | |
import rule from '../../../src/rules/lang'; | |
// ----------------------------------------------------------------------------- | |
// Tests | |
// ----------------------------------------------------------------------------- | |
const ruleTester = new RuleTester(); | |
const expectedError = { | |
message: 'lang attribute must have a valid value.', | |
type: 'JSXAttribute', | |
}; | |
const componentsSettings = { | |
'jsx-a11y': { | |
components: { | |
Foo: 'html', | |
}, | |
}, | |
}; | |
ruleTester.run('lang', rule, { | |
valid: [ | |
{ code: '<div />;' }, | |
{ code: '<div foo="bar" />;' }, | |
{ code: '<div lang="foo" />;' }, | |
{ code: '<html lang="en" />' }, | |
{ code: '<html lang="en-US" />' }, | |
{ code: '<html lang="zh-Hans" />' }, | |
{ code: '<html lang="zh-Hant-HK" />' }, | |
{ code: '<html lang="zh-yue-Hant" />' }, | |
{ code: '<html lang="ja-Latn" />' }, | |
{ code: '<html lang={foo} />' }, | |
{ code: '<HTML lang="foo" />' }, | |
{ code: '<Foo lang={undefined} />' }, | |
{ code: '<Foo lang="en" />', settings: componentsSettings }, | |
].map(parserOptionsMapper), | |
invalid: [ | |
{ code: '<html lang="foo" />', errors: [expectedError] }, | |
{ code: '<html lang="zz-LL" />', errors: [expectedError] }, | |
{ code: '<html lang={undefined} />', errors: [expectedError] }, | |
{ code: '<Foo lang={undefined} />', settings: componentsSettings, errors: [expectedError] }, | |
].map(parserOptionsMapper), | |
}); |