-
-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into n-chardon-fix-issue510
- Loading branch information
Showing
63 changed files
with
397 additions
and
163 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* eslint-disable import/prefer-default-export, no-underscore-dangle */ | ||
import * as axe from 'axe-core'; | ||
|
||
export function axeFailMessage(checkId, data) { | ||
return axe._audit.data.checks[checkId].messages.fail(data); | ||
} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* eslint-env jest */ | ||
/** | ||
* @fileoverview Ensure autocomplete attribute is correct. | ||
* @author Wilco Fiers | ||
*/ | ||
|
||
// ----------------------------------------------------------------------------- | ||
// Requirements | ||
// ----------------------------------------------------------------------------- | ||
|
||
import { RuleTester } from 'eslint'; | ||
import parserOptionsMapper from '../../__util__/parserOptionsMapper'; | ||
import { axeFailMessage } from '../../__util__/axeMapping'; | ||
import rule from '../../../src/rules/autocomplete-valid'; | ||
|
||
// ----------------------------------------------------------------------------- | ||
// Tests | ||
// ----------------------------------------------------------------------------- | ||
|
||
const ruleTester = new RuleTester(); | ||
|
||
const invalidAutocomplete = [{ | ||
message: axeFailMessage('autocomplete-valid'), | ||
type: 'JSXOpeningElement', | ||
}]; | ||
|
||
const inappropriateAutocomplete = [{ | ||
message: axeFailMessage('autocomplete-appropriate'), | ||
type: 'JSXOpeningElement', | ||
}]; | ||
|
||
ruleTester.run('autocomplete-valid', rule, { | ||
valid: [ | ||
// INAPPLICABLE | ||
{ code: '<input type="text" />;' }, | ||
// // PASSED AUTOCOMPLETE | ||
{ code: '<input type="text" autocomplete="name" />;' }, | ||
{ code: '<input type="text" autocomplete="" />;' }, | ||
{ code: '<input type="text" autocomplete="off" />;' }, | ||
{ code: '<input type="text" autocomplete="on" />;' }, | ||
{ code: '<input type="text" autocomplete="billing family-name" />;' }, | ||
{ code: '<input type="text" autocomplete="section-blue shipping street-address" />;' }, | ||
{ code: '<input type="text" autocomplete="section-somewhere shipping work email" />;' }, | ||
{ code: '<input type="text" autocomplete />;' }, | ||
{ code: '<input type="text" autocomplete={autocompl} />;' }, | ||
{ code: '<input type="text" autocomplete={autocompl || "name"} />;' }, | ||
{ code: '<input type="text" autocomplete={autocompl || "foo"} />;' }, | ||
{ code: '<Foo autocomplete="bar"></Foo>;' }, | ||
].map(parserOptionsMapper), | ||
invalid: [ | ||
// FAILED "autocomplete-valid" | ||
{ code: '<input type="text" autocomplete="foo" />;', errors: invalidAutocomplete }, | ||
{ code: '<input type="text" autocomplete="name invalid" />;', errors: invalidAutocomplete }, | ||
{ code: '<input type="text" autocomplete="invalid name" />;', errors: invalidAutocomplete }, | ||
{ code: '<input type="text" autocomplete="home url" />;', errors: invalidAutocomplete }, | ||
{ code: '<Bar autocomplete="baz"></Bar>;', errors: invalidAutocomplete, options: [{ inputComponents: ['Bar'] }] }, | ||
|
||
// FAILED "autocomplete-appropriate" | ||
{ code: '<input type="date" autocomplete="email" />;', errors: inappropriateAutocomplete }, | ||
{ code: '<input type="number" autocomplete="url" />;', errors: inappropriateAutocomplete }, | ||
{ code: '<input type="month" autocomplete="tel" />;', errors: inappropriateAutocomplete }, | ||
{ code: '<Foo type="month" autocomplete="tel"></Foo>;', errors: inappropriateAutocomplete, options: [{ inputComponents: ['Foo'] }] }, | ||
].map(parserOptionsMapper), | ||
}); |
Oops, something went wrong.