Skip to content

Commit

Permalink
fix: adds I18nT keyword into key collection (#471)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
advisciglio and ota-meshi authored Feb 20, 2024
1 parent 13e7d06 commit a12cbec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
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

0 comments on commit a12cbec

Please sign in to comment.