eslint-plugin-m6web-i18n
This is an eslint plugin for i18n in a react application.
Installation
yarn add -D eslint-plugin-m6web-i18n
Rules
- i18n/no-unknown-key: Verify that there all translation key you use are present in your primary translation files.
- i18n/no-unknown-key-secondary-langs: Same as the previous one. Allow you to have a different error level for secondary languages.
- i18n/no-text-as-children: Verify that you have no text children in your react code.
Config
You have to add the following lines in your .eslintrc
file to configure this plugin:
"plugins": [
"i18n"
],
"rules": {
"i18n/no-unknown-key": "error",
"i18n/no-unknown-key-secondary-langs": "warn",
"i18n/no-text-as-children": "error"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"settings": {
"i18n": {
"principalLangs": [
{
"name": "fr",
"translationPath": "i18n/fr.json"
}
],
"secondaryLangs": [
{
"name": "en",
"translationPath": "i18n/en.json"
}
],
"functionName": "t",
"ignoreFiles": "spec.js",
"pluralizedKeys": ["one", "other"]
}
}