Skip to content

Commit 08cbd06

Browse files
authored
Change no-missing-keys and no-dynamic-keys rules to also verify the keys used in the <i18n-t> component. (#93)
1 parent 252d125 commit 08cbd06

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

lib/rules/no-dynamic-keys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function create (context) {
5656
checkDirective(context, node)
5757
},
5858

59-
'VElement[name=i18n] > VStartTag > VAttribute[directive=true] > VDirectiveKey' (node) {
59+
'VElement:matches([name=i18n], [name=i18n-t]) > VStartTag > VAttribute[directive=true] > VDirectiveKey' (node) {
6060
checkComponent(context, node)
6161
},
6262

lib/rules/no-missing-keys.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ function create (context) {
1818
checkDirective(context, node)
1919
},
2020

21-
"VElement[name=i18n] > VStartTag > VAttribute[key.name='path']" (node) {
21+
"VElement:matches([name=i18n], [name=i18n-t]) > VStartTag > VAttribute[key.name='path']" (node) {
2222
checkComponent(context, node)
2323
},
2424

25-
"VElement[name=i18n] > VStartTag > VAttribute[key.name.name='path']" (node) {
25+
"VElement:matches([name=i18n], [name=i18n-t]) > VStartTag > VAttribute[key.name.name='path']" (node) {
2626
checkComponent(context, node)
2727
},
2828

tests/lib/rules/no-dynamic-keys.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ tester.run('no-dynamic-keys', rule, {
6464
errors: [
6565
`'missing' dynamic key is used'`
6666
]
67+
}, {
68+
// using <i18n-t> functional component in template block
69+
code: `<template>
70+
<i18n-t :path="missing"/>
71+
</template>`,
72+
errors: [
73+
`'missing' dynamic key is used'`
74+
]
6775
}, {
6876
// using custom directive in template block
6977
code: `<template>

tests/lib/rules/no-missing-keys.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ tester.run('no-missing-keys', rule, {
134134
`'missing' does not exist in 'en'`,
135135
`'missing' does not exist in 'ja'`
136136
]
137+
}, {
138+
// using <i18n-t> functional component in template block
139+
code: `<template>
140+
<div id="app">
141+
<i18n-t path="missing"/>
142+
</div>
143+
</template>`,
144+
errors: [
145+
`'missing' does not exist in 'en'`,
146+
`'missing' does not exist in 'ja'`
147+
]
137148
}, {
138149
// nested basic
139150
code: `$t('missing.path')`,

0 commit comments

Comments
 (0)