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.

testingserialization
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 is loaded via ESLint config, not directly imported in code.

// In .eslintrc plugins array "plugins": ["i18n-json"]

Use the plugin prefix 'plugin:' for accessing rulesets.

// .eslintrc extends: ["plugin:i18n-json/recommended"]

All rules must be namespaced with 'i18n-json/' prefix.

// .eslintrc rules "i18n-json/valid-json": "error"

Flat config requires ESM import of the plugin object.

import i18nJson from 'eslint-plugin-i18n-json'; export default [ { plugins: { 'i18n-json': i18nJson }, rules: { 'i18n-json/valid-json': 'error' } } ];

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 footguns
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.
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.
deprecatedLodash per-function packages (like lodash.get, lodash.set) were deprecated and removed; internal usage migrated to main lodash in v4.0.1.
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').
breakingFlat config (ESLint >=9) changes how plugins are loaded; CJS require() will not work; must use ESM import.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
13 hits · last 30 days
gptbot
4
ahrefsbot
4
amazonbot
4
script
1
Resources