Registry / testing / eslint-plugin-i18n-json

eslint-plugin-i18n-json

JSON →
library4.0.1jsnpmunverified

An ESLint plugin for linting JSON i18n translation files, version 4.0.1. It validates JSON syntax, ICU message syntax, checks identical keys across locales, sorts keys, and ensures placeholder consistency. Requires ESLint >=4.0.0. Maintained by GoDaddy with a focus on fully extendable rules and settings (e.g., custom message syntax, custom sort, key ignoring). Supports flat config (ESLint >=9) and nested keys. Release cadence is intermittent; last update April 2024 fixing Lodash deprecation.

npm install eslint-plugin-i18n-json
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-I18N
E
eslint-plugin-i18n-json
testingjavascriptv4.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin (eslint config)
// In .eslintrc plugins array "plugins": ["i18n-json"]
const plugin = require('eslint-plugin-i18n-json'); // Direct require is not typical; use config file plugins field
Plugin is loaded via ESLint config, not directly imported in code.
recommended config
// .eslintrc extends: ["plugin:i18n-json/recommended"]
extends: ["eslint-plugin-i18n-json"]
Use the plugin prefix 'plugin:' for accessing rulesets.
individual rule
// .eslintrc rules "i18n-json/valid-json": "error"
"valid-json": "error"
All rules must be namespaced with 'i18n-json/' prefix.
flat config (ESLint >=9)
import i18nJson from 'eslint-plugin-i18n-json'; export default [ { plugins: { 'i18n-json': i18nJson }, rules: { 'i18n-json/valid-json': 'error' } } ];
const i18nJson = require('eslint-plugin-i18n-json'); // CJS not supported in flat config; use import
Flat config requires ESM import of the plugin object.

Install the plugin and ESLint, configure .eslintrc.json with recommended rules and identical-keys, create sample translation files, and run ESLint.

npm install --save-dev eslint-plugin-i18n-json eslint # Create .eslintrc.json in project root cat > .eslintrc.json << 'EOF' { "plugins": ["i18n-json"], "extends": ["plugin:i18n-json/recommended"], "rules": { "i18n-json/identical-keys": ["error", { "filePath": "./translations/en-US/index.json" }], "i18n-json/identical-placeholders": "error" }, "settings": { "i18n-json/ignore-keys": ["_metadata"] } } EOF # Create sample translation files mkdir -p translations/en-US translations/es-MX echo '{"greeting": "Hello", "farewell": "Goodbye"}' > translations/en-US/index.json echo '{"greeting": "Hola", "farewell": "Adiós"}' > translations/es-MX/index.json # Run ESLint on the translation directory npx eslint translations/
Debug
Known issues
gotchaThe identical-keys rule requires a reference locale file path specified via 'filePath' option; without it, the rule will not work and may produce confusing errors.
fix
Add the 'filePath' option to the rule configuration pointing to your source locale file (e.g., './translations/en-US/index.json').
affects: >=1.0.0
gotchaThe default sort for sorted-keys is case-sensitive ascending. If your project uses case-insensitive or natural sort, you must provide a custom sort function.
fix
Configure a custom sort function in rule options: `"i18n-json/sorted-keys": ["error", { "sortFunction": "natural" }]` or a custom comparator.
affects: >=1.0.0
deprecatedLodash per-function packages (like lodash.get, lodash.set) were deprecated and removed; internal usage migrated to main lodash in v4.0.1.
fix
Update to v4.0.1 or above to avoid deprecated modules.
affects: >=4.0.0
gotchaThe plugin does not lint files outside of the ESLint file glob; you must include your translation files in ESLint's 'overrides' or include patterns (e.g., 'translations/**/*.json').
fix
Add an overrides block in .eslintrc: `"overrides": [{ "files": ["translations/**/*.json"], "rules": { ... } }]`.
affects: >=1.0.0
breakingFlat config (ESLint >=9) changes how plugins are loaded; CJS require() will not work; must use ESM import.
fix
Use `import i18nJson from 'eslint-plugin-i18n-json'` and attach as object property in flat config array.
affects: >=9.0.0 (ESLint)
Errors
Common errors & fixes
Error: ESLint configuration in .eslintrc is invalid: - Unexpected top-level property "i18n-json/ignore-keys"
Settings for i18n-json/ignore-keys must be placed under the 'settings' key, not at the top level of .eslintrc.
fix
Move `"i18n-json/ignore-keys": [...]` inside the `"settings"` object: `{ "settings": { "i18n-json/ignore-keys": [...] } }`.
Error: Cannot find module '@formatjs/icu-messageformat-parser'
The plugin requires @formatjs/icu-messageformat-parser for the default valid-message-syntax rule; it is not installed automatically.
fix
Run `npm install --save-dev @formatjs/icu-messageformat-parser` or disable the rule if not needed.
Error: Failed to load plugin 'i18n-json': Cannot find module 'eslint-plugin-i18n-json'
The plugin is not installed or ESLint cannot resolve it; common in monorepos without hoisting.
fix
Ensure `eslint-plugin-i18n-json` is listed in devDependencies and installed. If using workspaces, ensure the package is in the root node_modules.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency, required for plugin to function
@formatjs/icu-messageformat-parseroptionalused by default valid-message-syntax rule for ICU parsing
lodashrequiredutility library for internal operations (removed deprecated per-function packages in v4.0.1)
Agent activity
4 hits · last 30 days
node
4
Resources