Skip to content

Commit

Permalink
Merge pull request #721 from jsx-eslint/dynamic-input-type-autocomplete
Browse files Browse the repository at this point in the history
Add failing test for autocomplete with dynamic type
  • Loading branch information
jessebeach authored Jul 4, 2020
2 parents 7a34e45 + 2c47f0a commit 31721bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions __tests__/src/rules/autocomplete-valid-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ruleTester.run('autocomplete-valid', rule, {
{ 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'] }] },
{ code: '<input type={isEmail ? "email" : "text"} autocomplete="none" />;', errors: invalidAutocomplete },

// FAILED "autocomplete-appropriate"
{ code: '<input type="date" autocomplete="email" />;', errors: inappropriateAutocomplete },
Expand Down
3 changes: 2 additions & 1 deletion src/rules/autocomplete-valid.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ module.exports = {
return;
}

const type = getLiteralPropValue(getProp(node.attributes, 'type'));
const { violations } = runVirtualRule('autocomplete-valid', {
nodeName: 'input',
attributes: {
autocomplete,
// Which autocomplete is valid depends on the input type
type: getLiteralPropValue(getProp(node.attributes, 'type')),
type: type === null ? undefined : type,
},
});

Expand Down

0 comments on commit 31721bd

Please sign in to comment.