Skip to content

Commit a4be0fc

Browse files
luizotcarvalhoLuiz Otávio Carvalho
and
Luiz Otávio Carvalho
authored
Support Pinia methods in vue/no-unused-properties (#2441)
Co-authored-by: Luiz Otávio Carvalho <[email protected]>
1 parent 52e0770 commit a4be0fc

File tree

2 files changed

+918
-190
lines changed

2 files changed

+918
-190
lines changed

Diff for: lib/rules/no-unused-properties.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,16 @@ module.exports = {
496496
let groupName = null
497497
if (/^mapMutations|mapActions$/u.test(node.callee.name)) {
498498
groupName = 'methods'
499-
} else if (/^mapState|mapGetters$/u.test(node.callee.name)) {
499+
} else if (
500+
/^mapState|mapGetters|mapWritableState$/u.test(node.callee.name)
501+
) {
500502
groupName = 'computed'
501503
}
502504

503505
if (!groupName || node.arguments.length === 0) return
504-
const arg = node.arguments[0]
506+
// On Pinia the store is always the first argument
507+
const arg =
508+
node.arguments.length === 2 ? node.arguments[1] : node.arguments[0]
505509
if (arg.type === 'ObjectExpression') {
506510
// e.g.
507511
// `mapMutations({ add: 'increment' })`

0 commit comments

Comments
 (0)