Skip to content

Commit

Permalink
[Fix] button-has-type: fix exception for <button type>
Browse files Browse the repository at this point in the history
  • Loading branch information
meowtec committed Mar 23, 2022
1 parent 2145e29 commit 458ebfc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/button-has-type.js
Expand Up @@ -126,7 +126,7 @@ module.exports = {
return;
}

if (typeProp.value.type === 'JSXExpressionContainer') {
if (typeProp.value && typeProp.value.type === 'JSXExpressionContainer') {
checkExpression(node, typeProp.value.expression);
return;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/button-has-type.js
Expand Up @@ -179,6 +179,15 @@ ruleTester.run('button-has-type', rule, {
},
],
},
{
code: '<button type/>',
errors: [
{
messageId: 'invalidValue',
data: { value: true },
},
],
},
{
code: '<button type={condition ? "reset" : "button"}/>',
options: [{ reset: false }],
Expand Down

0 comments on commit 458ebfc

Please sign in to comment.