/** * @fileoverview Enforce lang attribute has a valid value. * @author Ethan Cohen */ // ----------------------------------------------------------------------------- // Requirements // ----------------------------------------------------------------------------- import { RuleTester } from 'eslint'; import parserOptionsMapper from '../../__util__/parserOptionsMapper'; import parsers from '../../__util__/helpers/parsers'; 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': { polymorphicPropName: 'as', components: { Foo: 'html', }, }, }; ruleTester.run('lang', rule, { valid: parsers.all([].concat( { code: '
;' }, { code: '
;' }, { code: '
;' }, { code: '
' }, { code: '
' }, { code: '
' }, { code: '
' }, { code: '
' }, { code: '
' }, { code: '
' }, { code: '
' }, { code: '' }, { code: '', settings: componentsSettings }, { code: '', settings: componentsSettings }, )).map(parserOptionsMapper), invalid: parsers.all([].concat( { code: '
', errors: [expectedError] }, { code: '
', errors: [expectedError] }, { code: '
', errors: [expectedError] }, { code: '', settings: componentsSettings, errors: [expectedError] }, { code: '', settings: componentsSettings, errors: [expectedError] }, )).map(parserOptionsMapper), });