Skip to content

Commit 1a3d658

Browse files
committed
rename variable to propertiesDefinedByStoreHelpers, change it to be a set, use isStringLiteral util
1 parent 91790a3 commit 1a3d658

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/rules/no-undef-properties.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ module.exports = {
113113
const programNode = context.getSourceCode().ast
114114
/**
115115
* Property names identified as defined via a Vuex or Pinia helpers
116-
* @type {string[]}
116+
* @type {Set<string>}
117117
*/
118-
const propertiesDefinedByVuexOrPiniaHelpers = []
118+
const propertiesDefinedByStoreHelpers = new Set()
119119

120120
/**
121121
* @param {ASTNode} node
@@ -191,7 +191,7 @@ module.exports = {
191191
if (
192192
reserved.includes(name) ||
193193
ignores.some((ignore) => ignore.test(name)) ||
194-
propertiesDefinedByVuexOrPiniaHelpers.includes(name)
194+
propertiesDefinedByStoreHelpers.has(name)
195195
) {
196196
return
197197
}
@@ -366,22 +366,18 @@ module.exports = {
366366
? null
367367
: utils.getStaticPropertyName(prop)
368368
if (name) {
369-
propertiesDefinedByVuexOrPiniaHelpers.push(name)
369+
propertiesDefinedByStoreHelpers.add(name)
370370
}
371371
}
372372
} else if (arg.type === 'ArrayExpression') {
373373
// e.g. `mapMutations(['add'])`
374374
for (const element of arg.elements) {
375-
if (
376-
!element ||
377-
(element.type !== 'Literal' &&
378-
element.type !== 'TemplateLiteral')
379-
) {
375+
if (!element || !utils.isStringLiteral(element)) {
380376
continue
381377
}
382378
const name = utils.getStringLiteralValue(element)
383379
if (name) {
384-
propertiesDefinedByVuexOrPiniaHelpers.push(name)
380+
propertiesDefinedByStoreHelpers.add(name)
385381
}
386382
}
387383
}

0 commit comments

Comments
 (0)