@@ -13,6 +13,7 @@ const utils = require('../utils')
13
13
/**
14
14
* @typedef {import('../utils').ComponentPropertyData } ComponentPropertyData
15
15
* @typedef {import('../utils').ComponentObjectPropertyData } ComponentObjectPropertyData
16
+ * @typedef {import('../utils').GroupName } GroupName
16
17
*
17
18
* @typedef {{[key: string]: ComponentPropertyData & { valueType: { type: string | null } }} } PropertyMap
18
19
*/
@@ -167,7 +168,7 @@ const getValueType = ({ property, propertyMap }) => {
167
168
}
168
169
169
170
/**
170
- * @param {Set<string > } groups
171
+ * @param {Set<GroupName > } groups
171
172
* @param {ObjectExpression } vueNodeMap
172
173
* @param {PropertyMap } propertyMap
173
174
*/
@@ -198,18 +199,15 @@ module.exports = {
198
199
} ,
199
200
/** @param {RuleContext } context */
200
201
create ( context ) {
202
+ /** @type {GroupName[] } */
201
203
const GROUP_NAMES = [ 'data' , 'props' , 'computed' , 'methods' ]
202
204
const groups = new Set ( GROUP_NAMES )
203
205
204
- /** @type PropertyMap */
205
- const propertyMap = { }
206
-
207
- /**@type ObjectExpression */
208
- let vueNodeMap = { }
206
+ /** @type {PropertyMap } */
207
+ const propertyMap = Object . create ( null )
209
208
210
209
return utils . defineVueVisitor ( context , {
211
210
onVueObjectEnter ( node ) {
212
- vueNodeMap = node
213
211
const properties = utils . iterateProperties ( node , groups )
214
212
215
213
for ( const property of properties ) {
@@ -222,8 +220,11 @@ module.exports = {
222
220
} ,
223
221
224
222
/** @param {ThisExpression } node */
225
- 'CallExpression > MemberExpression > ThisExpression' ( node ) {
226
- addPropertyMap ( groups , vueNodeMap , propertyMap )
223
+ 'CallExpression > MemberExpression > ThisExpression' (
224
+ node ,
225
+ { node : vueNode }
226
+ ) {
227
+ addPropertyMap ( groups , vueNode , propertyMap )
227
228
228
229
if ( node . parent . type !== 'MemberExpression' ) return
229
230
if ( node . parent . property . type !== 'Identifier' ) return
0 commit comments