@rotki/no-unused-i18n-keys
disallow unused i18n keys in locale files
- ⭐ The
"extends": "plugin:@rotki/recommended"property in a configuration file enables this rule. - ✒️️ The
--fixoption on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
This rule reports i18n keys defined in JSON or YAML locale files that are not referenced anywhere in the source code. It scans .vue and .ts files for usages of t(), te(), tc(), $t(), $te(), $tc(), this.$t(), <i18n-t keypath="...">, <i18n-t path="...">, v-t directives, and template literals like t(prefix.${dynamic}) (matched as wildcard prefixes).
The rule also recognizes linked messages (@:key and @:{key}) within locale files and treats them as used keys.
JSON locale file
YAML locale file
⚙️ Options
{
"@rotki/no-unused-i18n-keys": [
"error",
{
"src": "src",
"extensions": [".vue", ".ts"],
"ignoreKeys": []
}
]
}src (string)
The source directory to scan for i18n key usage. Default is "src".
extensions (string[])
File extensions to scan for i18n key usage. Default is [".vue", ".ts"].
ignoreKeys (string[])
Glob patterns for keys that should be ignored (not reported as unused). Uses * as a wildcard. Default is [].
{
"@rotki/no-unused-i18n-keys": [
"error",
{
"src": "src",
"extensions": [".vue", ".ts"],
"ignoreKeys": [
"backend_mappings.*",
"notification_messages.*",
"premium_components.*"
]
}
]
}💡 Features
- File-level caching — Parsed source files are cached by modification time, avoiding redundant parsing across locale files.
- Early bail-out — Files without i18n function calls are skipped without parsing.
- Template literal wildcards — Dynamic keys like
t(prefix.${val})are matched asprefix.*, covering all children. - Linked message detection — Keys referenced via
@:keyor@:{key}syntax in locale values are treated as used. - SFC
<i18n>block support — Keys defined in<i18n>blocks within Vue SFCs are included in the used keys set. - JSON and YAML support — Both JSON and YAML locale file formats are supported via
jsonc-eslint-parserandyaml-eslint-parser.
🚀 Version
This rule was introduced in @rotki/eslint-plugin v1.3.0