From a6647832f41b337865b7665cee8b80d9a5a5a7a7 Mon Sep 17 00:00:00 2001 From: Hasegawa-Yukihiro Date: Wed, 10 Apr 2024 15:03:40 +0900 Subject: [PATCH] [types] add type annotation for button-has-type rule --- lib/rules/button-has-type.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/rules/button-has-type.js b/lib/rules/button-has-type.js index 204a33c43e..a6411b9fe2 100644 --- a/lib/rules/button-has-type.js +++ b/lib/rules/button-has-type.js @@ -28,6 +28,7 @@ const messages = { forbiddenValue: '"{{value}}" is an invalid value for button type attribute', }; +/** @type {import('eslint').Rule.RuleModule} */ module.exports = { meta: { docs: { @@ -149,9 +150,11 @@ module.exports = { } const props = node.arguments[1].properties; - const typeProp = props.find((prop) => prop.key && prop.key.name === 'type'); + const typeProp = props.find( + (prop) => prop.type === 'Property' && prop.key.type === 'Identifier' && prop.key.name === 'type' + ); - if (!typeProp) { + if (typeProp.type !== 'Property') { reportMissing(node); return; }