Skip to content

Commit b6856ed

Browse files
committed
add test for button-has-type
1 parent 040d77c commit b6856ed

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/rules/button-has-type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ module.exports = {
157157
(prop) => prop.type === 'Property' && prop.key && prop.key.type === 'Identifier' && prop.key.name === 'type'
158158
);
159159

160-
if (typeProp.type !== 'Property') {
160+
if (!typeProp || typeProp.type !== 'Property') {
161161
reportMissing(node);
162162
return;
163163
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,14 @@ ruleTester.run('button-has-type', rule, {
304304
},
305305
],
306306
},
307+
{
308+
code: 'React.createElement("button", {...extraProps})',
309+
errors: [
310+
{
311+
messageId: 'missingType',
312+
},
313+
],
314+
},
307315
{
308316
code: 'Foo.createElement("button")',
309317
errors: [

0 commit comments

Comments
 (0)