eslint-plugin-i18next
raw JSON → 6.1.4 verified Sat Apr 25 auth: no javascript
ESLint plugin enforcing i18n best practices by flagging untranslated literal strings in JSX and JavaScript. Current stable version 6.1.4 is ESM-only, requires Node >=18.10, and ships TypeScript declarations. Breaking change in v6: default behavior only validates plain text in JSX markup (not all strings). Provides flat config support for ESLint 9 and legacy .eslintrc format for ESLint 8. Key differentiator: auto-fix is intentionally disabled because translation keys rarely match the literal string.
Common errors
error Error: Cannot find module 'eslint-plugin-i18next' ↓
cause Plugin not installed or not in node_modules.
fix
npm install eslint-plugin-i18next --save-dev
error TypeError: eslint-plugin-i18next is not a function or TypeError: i18next.configs is not iterable ↓
cause Using require() on v6 ESM package in CommonJS context.
fix
Switch to ESM: change file extension to .mjs or use dynamic import: const i18next = await import('eslint-plugin-i18next');
error ESLint couldn't find the plugin "eslint-plugin-i18next". ↓
cause Plugin not listed in plugins array of flat config.
fix
Add
plugins: { i18next } or use the spread config: ...i18next.configs['flat/recommended'] error Definition for rule 'i18next/no-literal-string' was not found ↓
cause Plugin not loaded correctly or rule name typo.
fix
Ensure the plugin is in plugins array and rule is spelled 'i18next/no-literal-string' (not 'i18n/no-literal-string').
Warnings
breaking v6 changed default no-literal-string mode from 'all' to 'jsx-text-only'. Existing projects may miss untranslated strings in non-JSX contexts. ↓
fix Explicitly set mode: 'all' in rule options to restore v5 behavior.
breaking v6 drops support for Node versions below 18.10.0. Installments on older Node fail or break. ↓
fix Upgrade Node to >=18.10.0 or pin plugin to version 5.x.
breaking v6 is ESM-only. Any require() call will throw ERR_REQUIRE_ESM. ↓
fix Use import syntax or migrate to dynamic import().
breaking Legacy .eslintrc config no longer works with ESLint 9 flat config. Mixing formats breaks. ↓
fix Use flat config with i18next.configs['flat/recommended'] in eslint.config.mjs.
deprecated v5 and below are deprecated and will stop receiving updates. v6 rewrote the plugin. ↓
fix Upgrade to v6 and migrate configuration accordingly.
Install
npm install eslint-plugin-i18next yarn add eslint-plugin-i18next pnpm add eslint-plugin-i18next Imports
- default (i18next) wrong
const i18next = require('eslint-plugin-i18next');correctimport i18next from 'eslint-plugin-i18next'; - configs['flat/recommended'] wrong
require('eslint-plugin-i18next').configs['flat/recommended']correctimport i18next from 'eslint-plugin-i18next'; // in eslint.config.mjs i18next.configs['flat/recommended'] - recommended (legacy) wrong
require('eslint-plugin-i18next').configs.recommendedcorrect// .eslintrc { "extends": ["plugin:i18next/recommended"] } - rule: no-literal-string wrong
import { rules } from 'eslint-plugin-i18next'; rules['no-literal-string']correct// .eslintrc { "rules": { "i18next/no-literal-string": "error" } }
Quickstart
// eslint.config.mjs
import i18next from 'eslint-plugin-i18next';
export default [
{
files: ['**/*.{js,jsx,mjs,ts,tsx}'],
...i18next.configs['flat/recommended'],
},
// override to only validate JSX text (v6 default)
{
rules: {
'i18next/no-literal-string': ['error', { mode: 'jsx-text-only' }]
}
}
];