@@ -35,9 +35,8 @@ module.exports = {
35
35
*/
36
36
/** @type {Map<FunctionDeclaration | FunctionExpression | ArrowFunctionExpression | Program, ScopePropsReferences> } */
37
37
const setupScopePropsReferenceIds = new Map ( )
38
- const outerExpressionTypes = new Set ( [
38
+ const wrapperExpressionTypes = new Set ( [
39
39
'ArrayExpression' ,
40
- 'CallExpression' ,
41
40
'ObjectExpression'
42
41
] )
43
42
@@ -68,27 +67,11 @@ module.exports = {
68
67
69
68
const rightNode = utils . skipChainExpression ( right )
70
69
71
- if ( outerExpressionTypes . has ( rightNode . type ) ) {
72
- const propRefs = [ ...propsReferences . refs . values ( ) ]
73
- const isPropsMemberAccessed = propRefs . some ( ( props ) => {
74
- const isPropsInCallExpression = utils . inRange ( rightNode . range , props )
75
-
76
- if ( isPropsInCallExpression ) {
77
- const isPropMemberExpression =
78
- props . parent . type === 'MemberExpression' &&
79
- props . parent . object === props
80
-
81
- if ( isPropMemberExpression ) {
82
- return true
83
- }
84
- }
85
-
86
- return false
87
- } )
88
-
89
- if ( isPropsMemberAccessed ) {
90
- return report ( left , 'getProperty' , propsReferences . scopeName )
91
- }
70
+ if (
71
+ wrapperExpressionTypes . has ( rightNode . type ) &&
72
+ isPropsMemberAccessed ( rightNode , propsReferences )
73
+ ) {
74
+ return report ( rightNode , 'getProperty' , propsReferences . scopeName )
92
75
}
93
76
94
77
if (
@@ -108,6 +91,24 @@ module.exports = {
108
91
report ( left , 'getProperty' , propsReferences . scopeName )
109
92
}
110
93
}
94
+
95
+ /**
96
+ * @param {Expression } node
97
+ * @param {ScopePropsReferences } propsReferences
98
+ */
99
+ function isPropsMemberAccessed ( node , propsReferences ) {
100
+ const propRefs = [ ...propsReferences . refs . values ( ) ]
101
+
102
+ return propRefs . some ( ( props ) => {
103
+ const isPropsInExpressionRange = utils . inRange ( node . range , props )
104
+ const isPropsMemberExpression =
105
+ props . parent . type === 'MemberExpression' &&
106
+ props . parent . object === props
107
+
108
+ return isPropsInExpressionRange && isPropsMemberExpression
109
+ } )
110
+ }
111
+
111
112
/**
112
113
* @typedef {object } ScopeStack
113
114
* @property {ScopeStack | null } upper
@@ -182,6 +183,26 @@ module.exports = {
182
183
183
184
setupScopePropsReferenceIds . delete ( node )
184
185
} ,
186
+ /**
187
+ * @param {CallExpression } node
188
+ */
189
+ CallExpression ( node ) {
190
+ if ( ! scopeStack ) {
191
+ return
192
+ }
193
+
194
+ const propsReferenceIds = setupScopePropsReferenceIds . get (
195
+ scopeStack . scopeNode
196
+ )
197
+
198
+ if ( ! propsReferenceIds ) {
199
+ return
200
+ }
201
+
202
+ if ( isPropsMemberAccessed ( node , propsReferenceIds ) ) {
203
+ report ( node , 'getProperty' , propsReferenceIds . scopeName )
204
+ }
205
+ } ,
185
206
/**
186
207
* @param {VariableDeclarator } node
187
208
*/
0 commit comments