Skip to content

Commit 458ebfc

Browse files
committed
[Fix] button-has-type: fix exception for <button type>
1 parent 2145e29 commit 458ebfc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/rules/button-has-type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ module.exports = {
126126
return;
127127
}
128128

129-
if (typeProp.value.type === 'JSXExpressionContainer') {
129+
if (typeProp.value && typeProp.value.type === 'JSXExpressionContainer') {
130130
checkExpression(node, typeProp.value.expression);
131131
return;
132132
}

tests/lib/rules/button-has-type.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ ruleTester.run('button-has-type', rule, {
179179
},
180180
],
181181
},
182+
{
183+
code: '<button type/>',
184+
errors: [
185+
{
186+
messageId: 'invalidValue',
187+
data: { value: true },
188+
},
189+
],
190+
},
182191
{
183192
code: '<button type={condition ? "reset" : "button"}/>',
184193
options: [{ reset: false }],

0 commit comments

Comments
 (0)