Skip to content

Commit d885a36

Browse files
committed
refactor: use findProperty
1 parent 7459eea commit d885a36

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

lib/rules/no-use-computed-property-like-method.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,10 @@ const getComponentPropsType = (property) => {
4444
* Check object props `props: { objectProps: {...} }`
4545
*/
4646
if (property.property.value.type === 'ObjectExpression') {
47-
const propsIncludeTypeProperty = property.property.value.properties.find(
48-
(property) =>
49-
property.type === 'Property' &&
50-
property.key.type === 'Identifier' &&
51-
property.key.name === 'type' &&
52-
property.value.type === 'Identifier'
53-
)
54-
55-
if (propsIncludeTypeProperty === undefined) return null
56-
57-
if (
58-
propsIncludeTypeProperty.type === 'Property' &&
59-
propsIncludeTypeProperty.value.type === 'Identifier'
60-
)
61-
return propsIncludeTypeProperty.value.name
47+
const typeProperty = utils.findProperty(property.property.value, 'type')
48+
if (typeProperty == null) return null
49+
50+
if (typeProperty.value.type === 'Identifier') return typeProperty.value.name
6251
}
6352
return null
6453
}

0 commit comments

Comments
 (0)