Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-eyes-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@intlify/eslint-plugin-vue-i18n": minor
---

fix: adds I18nT keyword into key collection
9 changes: 6 additions & 3 deletions lib/utils/collect-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,14 @@ export function collectKeysFromAST(
if (
(node.key.name === 'path' &&
(node.parent.parent.name === 'i18n' ||
node.parent.parent.name === 'i18n-t')) ||
(node.key.name === 'keypath' && node.parent.parent.name === 'i18n-t')
node.parent.parent.name === 'i18n-t' ||
node.parent.parent.rawName === 'I18nT')) ||
(node.key.name === 'keypath' &&
(node.parent.parent.name === 'i18n-t' ||
node.parent.parent.rawName === 'I18nT'))
) {
debug(
"call VElement:matches([name=i18n], [name=i18n-t]) > VStartTag > VAttribute[key.name='path'] handling ..."
"call VElement:matches([name=i18n], [name=i18n-t], [name=I18nT]) > VStartTag > VAttribute[key.name='path'] handling ..."
)

const key = getKeyFromI18nComponent(node)
Expand Down
16 changes: 16 additions & 0 deletions tests/lib/rules/no-unused-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ new RuleTester({
</i18n>
`
},
{
// <I18nT> component
filename: 'test.vue',
code: `
<template>
<I18nT keypath="message_key" tag="p" />
</template>
<i18n>
{
"en": {
"message_key": "hi"
}
}
</i18n>
`
},
{
// yaml supports
filename: 'test.vue',
Expand Down