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

no-message-keys warns when using <i18n> components and <i18n> blocks. #90

Closed
mandragorn opened this issue Aug 5, 2020 · 2 comments · Fixed by #92
Closed

no-message-keys warns when using <i18n> components and <i18n> blocks. #90

mandragorn opened this issue Aug 5, 2020 · 2 comments · Fixed by #92
Labels
Type: Bug Bug or Bug fixes

Comments

@mandragorn
Copy link

mandragorn commented Aug 5, 2020

I'm using version v0.7.0 of eslint-plugin-vue-i18n (which includes PR #80) and I'm getting an error that the message keys are not used when they are present for the path prop of an <i18n> component.

Simplified Test.vue:

<template>
  <i18n path="message_key" tag="p" />
</template>

<i18n>
{
  "en": {
    "message_key": "hi"
  }
}
</i18n>

.eslintrc.js:

module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: [
    'plugin:vue/essential',
    'eslint:recommended',
    '@vue/prettier',
    'plugin:@intlify/vue-i18n/recommended'
  ],
  parserOptions: {
    parser: 'babel-eslint'
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'prettier/prettier': [
      'warn',
      {
        singleQuote: true,
        trailingCommas: 'none',
        vueIndentScriptAndStyle: true
      }
    ],
    '@intlify/vue-i18n/no-html-messages': 'error',
    '@intlify/vue-i18n/no-missing-keys': 'error',
    '@intlify/vue-i18n/no-raw-text': 'error',
    '@intlify/vue-i18n/no-v-html': 'error',
    '@intlify/vue-i18n/no-dynamic-keys': 'error',
    '@intlify/vue-i18n/no-unused-keys': 'error'
  },
  overrides: [
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)'
      ],
      env: {
        jest: true
      }
    }
  ],
  settings: {
    'vue-i18n': {
      localeDir: {
        pattern: './*.vue',
        localeKey: 'key'
      }
    }
  }
};

Error when running lint:

error: unused 'en.message_key' key (@intlify/vue-i18n/no-unused-keys) at src/components/Test.vue:8:5:
   6 | {
   7 |   "en": {
>  8 |     "message_key": "hi"
     |     ^
   9 |   }
  10 | }
  11 | </i18n>

Dependencies:


  "dependencies": {
    "axios": "^0.18.0",
    "core-js": "^3.6.5",
    "moment": "^2.27.0",
    "v-mask": "^2.2.3",
    "vue": "^2.6.11",
    "vue-i18n": "^8.20.0",
    "vue-router": "^3.2.0",
    "vuejs-logger": "^1.5.3",
    "vuelidate": "^0.7.5",
    "vuex": "^3.4.0"
  },
  "devDependencies": {
    "@intlify/eslint-plugin-vue-i18n": "^0.7.0",
    "@intlify/vue-i18n-loader": "^1.0.0",
    "@kazupon/vue-i18n-loader": "^0.5.0",
    "@vue/cli-plugin-babel": "~4.4.0",
    "@vue/cli-plugin-e2e-cypress": "~4.4.0",
    "@vue/cli-plugin-eslint": "~4.4.0",
    "@vue/cli-plugin-pwa": "^4.4.6",
    "@vue/cli-plugin-router": "~4.4.0",
    "@vue/cli-plugin-unit-jest": "~4.4.0",
    "@vue/cli-plugin-vuex": "~4.4.0",
    "@vue/cli-service": "~4.4.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/test-utils": "^1.0.3",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.8.0",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-vue": "^6.2.2",
    "lint-staged": "^9.5.0",
    "node-sass": "^4.12.0",
    "npm-force-resolutions": "0.0.3",
    "prettier": "^1.19.1",
    "register-service-worker": "^1.7.1",
    "sass-loader": "^8.0.2",
    "vue-cli-plugin-i18n": "~1.0.1",
    "vue-template-compiler": "^2.6.11",
    "workbox-webpack-plugin": "^5.1.3"
  },

Originally posted by @mandragorn in #70 (comment)

@ota-meshi
Copy link
Member

Thank you for this issue!
It seems a bug.

@mandragorn
Copy link
Author

Thank you for the quick fix!

Is there a sense of what the release cadence is for this project? That way I have an idea of when to check back for a release that includes this fix.

Thanks again! ~Josh

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
2 participants