diff --git a/lib/rules/button-has-type.js b/lib/rules/button-has-type.js index add42d69ca..277f6c2a31 100644 --- a/lib/rules/button-has-type.js +++ b/lib/rules/button-has-type.js @@ -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; } diff --git a/tests/lib/rules/button-has-type.js b/tests/lib/rules/button-has-type.js index 8c7ab73955..be47c7e51e 100644 --- a/tests/lib/rules/button-has-type.js +++ b/tests/lib/rules/button-has-type.js @@ -179,6 +179,15 @@ ruleTester.run('button-has-type', rule, { }, ], }, + { + code: '