diff --git a/.changeset/khaki-eyes-serve.md b/.changeset/khaki-eyes-serve.md new file mode 100644 index 00000000..7b059fef --- /dev/null +++ b/.changeset/khaki-eyes-serve.md @@ -0,0 +1,5 @@ +--- +"@intlify/eslint-plugin-vue-i18n": minor +--- + +fix: adds I18nT keyword into key collection diff --git a/lib/utils/collect-keys.ts b/lib/utils/collect-keys.ts index d32a651e..c34b619f 100644 --- a/lib/utils/collect-keys.ts +++ b/lib/utils/collect-keys.ts @@ -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) diff --git a/tests/lib/rules/no-unused-keys.ts b/tests/lib/rules/no-unused-keys.ts index 93dedb28..ca53f4e4 100644 --- a/tests/lib/rules/no-unused-keys.ts +++ b/tests/lib/rules/no-unused-keys.ts @@ -94,6 +94,22 @@ new RuleTester({ ` }, + { + // component + filename: 'test.vue', + code: ` + + + { + "en": { + "message_key": "hi" + } + } + + ` + }, { // yaml supports filename: 'test.vue',