Skip to content

Commit 8d2657a

Browse files
authored
Fix false positives for <i18n-t keypath> in no-unused-key rule (#252)
1 parent 4f42dc3 commit 8d2657a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/utils/collect-keys.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,10 @@ export function collectKeysFromAST(
203203
}
204204
} else {
205205
if (
206-
node.key.name === 'path' &&
207-
(node.parent.parent.name === 'i18n' ||
208-
node.parent.parent.name === 'i18n-t')
206+
(node.key.name === 'path' &&
207+
(node.parent.parent.name === 'i18n' ||
208+
node.parent.parent.name === 'i18n-t')) ||
209+
(node.key.name === 'keypath' && node.parent.parent.name === 'i18n-t')
209210
) {
210211
debug(
211212
"call VElement:matches([name=i18n], [name=i18n-t]) > VStartTag > VAttribute[key.name='path'] handling ..."

tests/fixtures/no-unused-keys/invalid/constructor-option-format/src/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div id="app">
3-
<p v-t="'hello_dio'">{{ $t('messages.hello') }}</p>
3+
<i18n-t keypath=hello_dio></i18n-t>
4+
<p>{{ $t('messages.hello') }}</p>
45
</div>
56
</template>
67

0 commit comments

Comments
 (0)