nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: intlify/eslint-plugin-vue-i18n
Pull request #394 (2023-07-04 07:15:58)

fix: no-missing-keys rule reports false positive with trailing dot
(as noted in https://github.com/intlify/eslint-plugin-vue-i18n/issues/260#issuecomment-1618963764)

For a translation key like `$t('missing.')` the parse function from core utilities returns undefined.

Previously this was turned into an empty array which caused all of those paths to be false positives.

If the given key can't be parsed as "path" properly, the correct handling is to treat it as a single item path with the provided string as the only item.

This also revealed another faulty test, where `keypath="'hello'"` was passing even though it should not.

changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: c34b66379f16b18663233e34b299f317784ec93f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**



[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/wolfgangwalther/eslint-plugin-vue-i18n/new/fix-no-missing-keys-trailing-dot?filename=.changeset/strong-ways-care.md&value=---%0A%22%40fake-scope%2Ffake-pkg%22%3A%20patch%0A---%0A%0Afix%3A%20no-missing-keys%20rule%20reports%20false%20positive%20with%20trailing%20dot%0A)



Patch:
diff --git a/.changeset/forty-tools-dream.md b/.changeset/forty-tools-dream.md
new file mode 100644
index 0000000..8cfd2e5
--- /dev/null
+++ b/.changeset/forty-tools-dream.md
@@ -0,0 +1,5 @@
+---
+"@intlify/eslint-plugin-vue-i18n": patch
+---
+
+fix: no-missing-keys rule reports false positive with trailing dot
diff --git a/lib/utils/key-path.ts b/lib/utils/key-path.ts
index 659faec..6c40ed0 100644
--- a/lib/utils/key-path.ts
+++ b/lib/utils/key-path.ts
@@ -21,5 +21,5 @@ export function joinPath(...paths: (string | number)[]): string {
 }
 
 export function parsePath(path: string): string[] {
-  return parse(path) || []
+  return parse(path) || [path]
 }


Test patch:
diff --git a/tests/lib/rules/no-missing-keys.ts b/tests/lib/rules/no-missing-keys.ts
index c314e77..163c9dc 100644
--- a/tests/lib/rules/no-missing-keys.ts
+++ b/tests/lib/rules/no-missing-keys.ts
@@ -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>`
       },
       {
@@ -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')`,