Skip to content

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

@andruhon

Description

@andruhon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions