{"id":19781,"library":"eslint-plugin-i18n-json","title":"eslint-plugin-i18n-json","description":"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.","status":"active","version":"4.0.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/godaddy/eslint-plugin-i18n-json","tags":["javascript","eslint","json","i18n","translations","internationalization","intl","linter"],"install":[{"cmd":"npm install eslint-plugin-i18n-json","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-i18n-json","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-i18n-json","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, required for plugin to function","package":"eslint","optional":false},{"reason":"used by default valid-message-syntax rule for ICU parsing","package":"@formatjs/icu-messageformat-parser","optional":true},{"reason":"utility library for internal operations (removed deprecated per-function packages in v4.0.1)","package":"lodash","optional":false}],"imports":[{"note":"Plugin is loaded via ESLint config, not directly imported in code.","wrong":"const plugin = require('eslint-plugin-i18n-json'); // Direct require is not typical; use config file plugins field","symbol":"plugin (eslint config)","correct":"// In .eslintrc plugins array\n\"plugins\": [\"i18n-json\"]"},{"note":"Use the plugin prefix 'plugin:' for accessing rulesets.","wrong":"extends: [\"eslint-plugin-i18n-json\"]","symbol":"recommended config","correct":"// .eslintrc\nextends: [\"plugin:i18n-json/recommended\"]"},{"note":"All rules must be namespaced with 'i18n-json/' prefix.","wrong":"\"valid-json\": \"error\"","symbol":"individual rule","correct":"// .eslintrc rules\n\"i18n-json/valid-json\": \"error\""},{"note":"Flat config requires ESM import of the plugin object.","wrong":"const i18nJson = require('eslint-plugin-i18n-json'); // CJS not supported in flat config; use import","symbol":"flat config (ESLint >=9)","correct":"import i18nJson from 'eslint-plugin-i18n-json';\nexport default [\n  { plugins: { 'i18n-json': i18nJson }, rules: { 'i18n-json/valid-json': 'error' } }\n];"}],"quickstart":{"code":"npm install --save-dev eslint-plugin-i18n-json eslint\n\n# Create .eslintrc.json in project root\ncat > .eslintrc.json << 'EOF'\n{\n  \"plugins\": [\"i18n-json\"],\n  \"extends\": [\"plugin:i18n-json/recommended\"],\n  \"rules\": {\n    \"i18n-json/identical-keys\": [\"error\", { \"filePath\": \"./translations/en-US/index.json\" }],\n    \"i18n-json/identical-placeholders\": \"error\"\n  },\n  \"settings\": {\n    \"i18n-json/ignore-keys\": [\"_metadata\"]\n  }\n}\nEOF\n\n# Create sample translation files\nmkdir -p translations/en-US translations/es-MX\necho '{\"greeting\": \"Hello\", \"farewell\": \"Goodbye\"}' > translations/en-US/index.json\necho '{\"greeting\": \"Hola\", \"farewell\": \"Adiós\"}' > translations/es-MX/index.json\n\n# Run ESLint on the translation directory\nnpx eslint translations/","lang":"javascript","description":"Install the plugin and ESLint, configure .eslintrc.json with recommended rules and identical-keys, create sample translation files, and run ESLint."},"warnings":[{"fix":"Add the 'filePath' option to the rule configuration pointing to your source locale file (e.g., './translations/en-US/index.json').","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Configure a custom sort function in rule options: `\"i18n-json/sorted-keys\": [\"error\", { \"sortFunction\": \"natural\" }]` or a custom comparator.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update to v4.0.1 or above to avoid deprecated modules.","message":"Lodash per-function packages (like lodash.get, lodash.set) were deprecated and removed; internal usage migrated to main lodash in v4.0.1.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Add an overrides block in .eslintrc: `\"overrides\": [{ \"files\": [\"translations/**/*.json\"], \"rules\": { ... } }]`.","message":"The 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').","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `import i18nJson from 'eslint-plugin-i18n-json'` and attach as object property in flat config array.","message":"Flat config (ESLint >=9) changes how plugins are loaded; CJS require() will not work; must use ESM import.","severity":"breaking","affected_versions":">=9.0.0 (ESLint)"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Move `\"i18n-json/ignore-keys\": [...]` inside the `\"settings\"` object: `{ \"settings\": { \"i18n-json/ignore-keys\": [...] } }`.","cause":"Settings for i18n-json/ignore-keys must be placed under the 'settings' key, not at the top level of .eslintrc.","error":"Error: ESLint configuration in .eslintrc is invalid: - Unexpected top-level property \"i18n-json/ignore-keys\""},{"fix":"Run `npm install --save-dev @formatjs/icu-messageformat-parser` or disable the rule if not needed.","cause":"The plugin requires @formatjs/icu-messageformat-parser for the default valid-message-syntax rule; it is not installed automatically.","error":"Error: Cannot find module '@formatjs/icu-messageformat-parser'"},{"fix":"Ensure `eslint-plugin-i18n-json` is listed in devDependencies and installed. If using workspaces, ensure the package is in the root node_modules.","cause":"The plugin is not installed or ESLint cannot resolve it; common in monorepos without hoisting.","error":"Error: Failed to load plugin 'i18n-json': Cannot find module 'eslint-plugin-i18n-json'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}