Skip to content

Commit a12cbec

Browse files
advisciglioota-meshi
andauthoredFeb 20, 2024··
fix: adds I18nT keyword into key collection (#471)
* fix: adds I18nT keyword into key collection * Create khaki-eyes-serve.md * refactor: replace lowercase node name with pascal case raw name --------- Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
1 parent 13e7d06 commit a12cbec

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed
 

‎.changeset/khaki-eyes-serve.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@intlify/eslint-plugin-vue-i18n": minor
3+
---
4+
5+
fix: adds I18nT keyword into key collection

‎lib/utils/collect-keys.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,14 @@ export function collectKeysFromAST(
212212
if (
213213
(node.key.name === 'path' &&
214214
(node.parent.parent.name === 'i18n' ||
215-
node.parent.parent.name === 'i18n-t')) ||
216-
(node.key.name === 'keypath' && node.parent.parent.name === 'i18n-t')
215+
node.parent.parent.name === 'i18n-t' ||
216+
node.parent.parent.rawName === 'I18nT')) ||
217+
(node.key.name === 'keypath' &&
218+
(node.parent.parent.name === 'i18n-t' ||
219+
node.parent.parent.rawName === 'I18nT'))
217220
) {
218221
debug(
219-
"call VElement:matches([name=i18n], [name=i18n-t]) > VStartTag > VAttribute[key.name='path'] handling ..."
222+
"call VElement:matches([name=i18n], [name=i18n-t], [name=I18nT]) > VStartTag > VAttribute[key.name='path'] handling ..."
220223
)
221224

222225
const key = getKeyFromI18nComponent(node)

‎tests/lib/rules/no-unused-keys.ts

+16
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ new RuleTester({
9494
</i18n>
9595
`
9696
},
97+
{
98+
// <I18nT> component
99+
filename: 'test.vue',
100+
code: `
101+
<template>
102+
<I18nT keypath="message_key" tag="p" />
103+
</template>
104+
<i18n>
105+
{
106+
"en": {
107+
"message_key": "hi"
108+
}
109+
}
110+
</i18n>
111+
`
112+
},
97113
{
98114
// yaml supports
99115
filename: 'test.vue',

0 commit comments

Comments
 (0)
Please sign in to comment.