Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no-missing-keys rule reports false positive with trailing dot #394

Merged
merged 2 commits into from
Jul 22, 2023
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/forty-tools-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@intlify/eslint-plugin-vue-i18n": patch
---

fix: no-missing-keys rule reports false positive with trailing dot
2 changes: 1 addition & 1 deletion lib/utils/key-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export function joinPath(...paths: (string | number)[]): string {
}

export function parsePath(path: string): string[] {
return parse(path) || []
return parse(path) || [path]
}
9 changes: 8 additions & 1 deletion tests/lib/rules/no-missing-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ tester.run('no-missing-keys', rule as never, {
code: `
<i18n locale="en">{"hello": "hello"}</i18n>
<template>
<i18n-t keypath="'hello'"></i18n-t>
<i18n-t keypath="hello"></i18n-t>
</template>`
},
{
Expand Down Expand Up @@ -271,6 +271,13 @@ tester.run('no-missing-keys', rule as never, {
</template>`,
errors: [`'missing' does not exist in localization message resources`]
},
{
// missing ending with a dot
code: `$t('missing.')`,
errors: [
`'["missing."]' does not exist in localization message resources`
]
},
{
// nested basic
code: `$t('missing.path')`,
Expand Down
Loading