Skip to content

Commit ce93fa6

Browse files
committed
fix: support undefined of propertyMap[thisMember]
1 parent 3b77c4e commit ce93fa6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const getPrototypeType = (obj) =>
6363
/**
6464
* Get return type of property.
6565
* @param {{ property: ComponentPropertyData, propertyMap?: PropertyMap }} args
66-
* @returns {{type: string | null}}
66+
* @returns {{type: string | null | 'ReturnStatementHasNotArgument'}}
6767
*/
6868
const getValueType = ({ property, propertyMap }) => {
6969
if (property.type === 'array') {
@@ -94,7 +94,9 @@ const getValueType = ({ property, propertyMap }) => {
9494
)
9595

9696
if (!returnStatement || returnStatement.type !== 'ReturnStatement')
97-
return
97+
return {
98+
type: null
99+
}
98100

99101
if (returnStatement.argument === null)
100102
return {
@@ -231,7 +233,12 @@ module.exports = {
231233

232234
const thisMember = node.parent.property.name
233235

234-
if (!propertyMap[thisMember].valueType.type) return
236+
if (
237+
!propertyMap[thisMember] ||
238+
!propertyMap[thisMember].valueType ||
239+
!propertyMap[thisMember].valueType.type
240+
)
241+
return
235242

236243
if (
237244
propertyMap[thisMember].groupName === 'computed' &&

0 commit comments

Comments
 (0)