Skip to content

@intlify/vue-i18n/no-unused-keys

disallow unused localization keys

  • ✒️️ The --fix option on the command line can automatically fix some of the problems reported by this rule.

Localization keys that not used anywhere in the code are most likely an error due to incomplete refactoring. Such localization keys take up code size and can lead to confusion by readers.

📖 Rule Details

This rule is aimed at eliminating unused localization keys.

👎 Examples of incorrect code for this rule:

locale messages:

For SFC.

👍 Examples of correct code for this rule:

locale messages:

⚙️ Options

json
{
  "@intlify/vue-i18n/no-unused-keys": [
    "error",
    {
      "src": "./src",
      "extensions": [".js", ".vue"],
      "ignores": [],
      "enableFix": false
    }
  ]
}
  • src: specify the source codes directory to be able to lint. If you don't set any options, it set to process.cwd() as default.
  • extensions: an array to allow specified lintable target file extension. If you don't set any options, it set to .js and .vue as default.
  • ignores: An array of key names and patterns to exclude from the check. If you want to specify a pattern, specify a string such as /pattern/.
  • enableFix: if true, enable automatically remove unused keys on eslint --fix. If you don't set any options, it set to false as default. (This is an experimental feature.)

🚀 Version

This rule was introduced in @intlify/eslint-plugin-vue-i18n v0.1.0

🔍 Implementation