Skip to content

'no-missing-keys' doesn't respect fallback locale when accessing nested properties. #311

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

Closed
andruhon opened this issue Apr 5, 2022 · 0 comments · Fixed by #313
Closed
Labels
Type: Bug Bug or Bug fixes

Comments

@andruhon
Copy link

andruhon commented Apr 5, 2022

Tell us about your environment

  • ESLint version: 7.32.0
  • eslint-plugin-vue version: 8.0.3
  • eslint-plugin-vue-i18n version: 1.4.0
  • Node version: 16.14

Please show your full configuration:

(eslintConfig in package.json)

{
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended",
      "plugin:@intlify/vue-i18n/recommended"
    ],
    "parserOptions": {
      "parser": "@babel/eslint-parser"
    },
    "settings": {
      "vue-i18n": {
        "localeDir": "./src/locales/*.json"
      }
    },
    "rules": {}
}

What did you do?
Our project has multiple variations of english translations, with en-NZ as fallback language and a number of alternative variants such as catalogue vs catalog for AU and US. The fallback english supposed to have all the translations and other languages just have a few country-specific translations.

Lint displaying warning 'announcements.testNz' does not exist in localization message resources @intlify/vue-i18n/no-missing-keys for the message which is available in fallback locale.

This seems to be caused by the findMissingPath simply looking only in last locale (this was not the case with @intlify/eslint-plugin-vue-i18n 1.0.1).

See quickstart available at https://github.com/andruhon/NoUnusedKeysNestedJsonFalsePositiveQuickstart

What did you expect to happen?
I would expect the warning not to be issued if translation is available in primary/fallback locale.
The issue is only the case for nested properties. Flat properties are OK.

What actually happened?

  4:10  warning  'announcements.testNz' does not exist in localization message resources  @intlify/vue-i18n/no-missing-keys
  6:10  warning  'announcements.testUs' does not exist in localization message resources  @intlify/vue-i18n/no-missing-keys

✖ 2 problems (0 errors, 2 warnings)

Repository to reproduce this issue
https://github.com/andruhon/NoUnusedKeysNestedJsonFalsePositiveQuickstart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug or Bug fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants