ESLint plugin for Lingui
npm install eslint-plugin-linguiSet of eslint rules for Lingui projects





You'll first need to install ESLint:
``bash`
npm install --save-dev eslintor
yarn add eslint --dev
Next, install eslint-plugin-lingui:
`bash`
npm install --save-dev eslint-plugin-linguior
yarn add eslint-plugin-lingui --dev
Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-lingui globally.
)To enable all the recommended rules for our plugin, add the following config:
`js
import pluginLingui from 'eslint-plugin-lingui'
export default [
pluginLingui.configs['flat/recommended'],
// Any other config...
]
`
We also recommend enabling the no-unlocalized-strings rule. It’s not enabled by default because it needs to be set up specifically for your project. Please check the rule's documentation for example configurations.
Alternatively, you can load the plugin and configure only the rules you want to use:
`js
import pluginLingui from 'eslint-plugin-lingui'
export default [
{
plugins: {
lingui: pluginLingui,
},
rules: {
'lingui/t-call-in-function': 'error',
},
},
// Any other config...
]
`
)To enable all of the recommended rules for our plugin, add plugin:lingui/recommended in extends:
`json`
{
"extends": ["plugin:lingui/recommended"]
}
Alternatively, add lingui to the plugins section, and configure the rules you want to use:
`json``
{
"plugins": ["lingui"],
"rules": {
"lingui/t-call-in-function": "error"
}
}
✅ - Recommended
- ✅ no-expression-in-message
- ✅ no-single-tag-to-translate
- ✅ no-single-variables-to-translate
- ✅ no-trans-inside-trans
- ✅ t-call-in-function
- no-unlocalized-strings
- text-restrictions
- consistent-plural-format