Skip to content

Commit

Permalink
Fix false negatives for <i18n-t keypath> in no-missing-key rule (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Nov 16, 2021
1 parent be1fda7 commit cda51de
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/rules/no-missing-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ function create(context: RuleContext): RuleListener {
checkDirective(context, node)
},

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

"VElement:matches([name=i18n], [name=i18n-t]) > VStartTag > VAttribute[key.name.name='path']"(
["VElement:matches([name=i18n], [name=i18n-t]) > VStartTag > VAttribute[key.name='path']," +
"VElement[name=i18n-t] > VStartTag > VAttribute[key.name='keypath']"](
node: VAST.VAttribute
) {
checkComponent(context, node)
Expand Down
17 changes: 17 additions & 0 deletions tests/lib/rules/no-missing-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ tester.run('no-missing-keys', rule as never, {
<template>
<div id="app"></div>
</template>`
},
{
filename: 'test.vue',
code: `
<i18n locale="en">{"hello": "hello"}</i18n>
<template>
<i18n-t keypath="'hello'"></i18n-t>
</template>`
}
]
),
Expand Down Expand Up @@ -278,6 +286,15 @@ tester.run('no-missing-keys', rule as never, {
<p v-t="'missing'"></p>
</template>`,
errors: [`'missing' does not exist in localization message resources`]
},
{
filename: 'test.vue',
code: `
<i18n locale="en">{"hello": "hello"}</i18n>
<template>
<i18n-t keypath="hi"></i18n-t>
</template>`,
errors: [`'hi' does not exist in localization message resources`]
}
]
)
Expand Down

0 comments on commit cda51de

Please sign in to comment.