https://github.com/edvardchen/eslint-plugin-i18next
ESLint plugin for i18next. Prevent to display non-localized text for users
https://github.com/edvardchen/eslint-plugin-i18next
Last synced: about 1 year ago
JSON representation
ESLint plugin for i18next. Prevent to display non-localized text for users
- Host: GitHub
- URL: https://github.com/edvardchen/eslint-plugin-i18next
- Owner: edvardchen
- License: mit
- Created: 2019-03-29T07:38:50.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-11-24T13:27:04.000Z (over 1 year ago)
- Last Synced: 2025-04-27T16:46:18.236Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 639 KB
- Stars: 147
- Watchers: 3
- Forks: 39
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-i18next
ESLint plugin for i18n
> For old versions below v6, plz refer [this document](./v5.md)
## Installation
```bash
npm install eslint-plugin-i18next --save-dev
```
## Usage
For ESLint 9 flat configuration,
```js
// eslint.config.mjs
import i18next from 'eslint-plugin-i18next';
export default [
// your other configs
i18next.configs['flat/recommended'],
];
```
For ESLint 8 and below,
```json
// .eslintrc
{
"extends": ["plugin: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:
```js
/*eslint i18next/no-literal-string: "error"*/
hello world
```
Example of correct code:
```js
/*eslint i18next/no-literal-string: "error"*/
{i18next.t('HELLO_KEY')}
```
More options can be found [here](./docs/rules/no-literal-string.md)
### 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](./docs/rules/no-literal-string.md)