react-i18next-lint

raw JSON →
1.3.1 verified Fri May 01 auth: no javascript

A CLI tool for validating translation keys in react-i18next projects. v1.3.1 (latest). It scans React views and language JSON files to detect missing keys, zombie keys, empty translations, and misprint keys using regex matching. Offers configurable severity levels (disable/warning/error), deep search, and auto-fix for zombie keys. Differentiators: focused solely on react-i18next, supports URL-based language files, and includes misprint detection. Alternatives like i18next-scanner focus on extraction rather than validation. Released under semantic versioning with monthly updates.

error Error: ENOENT: no such file or directory, scandir './public/locales/en.json'
cause The language glob pattern does not match any existing files.
fix
Verify the path to language files; use --l './public/locales/**/*.json' to match nested files.
error Error: Cannot find module 'glob'
cause Missing dependency when running via npx with an older npm version.
fix
Install glob globally or use a recent npm version (>=7) that auto-installs peer dependencies.
error Warning: No translation keys found in views. Check your --project glob pattern.
cause The project glob pattern does not match any files with translation keys.
fix
Ensure the glob pattern includes file extensions like .jsx, .tsx, .js, .ts. Example: -p './src/**/*.{jsx,tsx}'
gotcha The --ds (deepSearch) option can significantly increase execution time on large projects.
fix Use deep search only when necessary; consider narrowing the project glob pattern.
gotcha The --mk (misprintKeys) option may produce false positives with coefficient 0.9.
fix Adjust --mc (misprintCoefficient) to a lower value (e.g., 0.8) to reduce false positives.
breaking Default severity for keysOnViews changed from 'warning' to 'error' in v1.1.0.
fix Explicitly set --kv warning if you want the old behavior.
deprecated The --fz (fixZombiesKeys) option is experimental and may be removed in future versions.
fix Use with caution; backup language files before auto-fix.
npm install react-i18next-lint
yarn add react-i18next-lint
pnpm add react-i18next-lint

Scans JSX/TSX files in src and JSON translation files in public/locales, reports missing keys as errors, zombie and empty keys as warnings.

npx react-i18next-lint -p "./src/**/*.{jsx,tsx}" -l "./public/locales/**/*.json" --kv error --zk warning --ek warning