@geoblink/eslint-plugin-i18next
v6.1.3
Published
ESLint plugin for i18n — MyTraffic fork of eslint-plugin-i18next, adding the no-missing-plural-count and no-empty-translation-string rules
Maintainers
Readme
@geoblink/eslint-plugin-i18next
ESLint plugin for i18n. MyTraffic's fork of
edvardchen/eslint-plugin-i18next,
published under the @geoblink scope because the two rules below don't exist
upstream:
no-missing-plural-countno-empty-translation-string
The version tracks the upstream release the fork is based on. no-literal-string
and everything else below is upstream's, unchanged.
For old versions below v6, plz refer this document
Installation
npm install @geoblink/eslint-plugin-i18next --save-devUsage
For ESLint 9 flat configuration,
// eslint.config.mjs
import i18next from '@geoblink/eslint-plugin-i18next';
export default [
// your other configs
i18next.configs['flat/recommended'],
];For ESLint 8 and below,
// .eslintrc
{
"extends": ["plugin:@geoblink/i18next/recommended"]
}Rule no-literal-string
This rule aims to avoid developers to display literal string directly to users without translating them.
Note: Disable auto-fix because key in the call
i18next.t(key)usually was not the same as the literal
Example of incorrect code:
/*eslint i18next/no-literal-string: "error"*/
<div>hello world</div>Example of correct code:
/*eslint i18next/no-literal-string: "error"*/
<div>{i18next.t('HELLO_KEY')}</div>More options can be found here
Breaking change
By default, it will only validate the plain text in JSX markup instead of all literal strings in previous versions. You can change it easily
