{"id":19808,"library":"eslint-plugin-json-files","title":"eslint-plugin-json-files","description":"ESLint plugin and processor for linting JSON files, particularly package.json. Current stable version 5.1.2 requires Node >=20.9 and ESLint >=5. It provides 11 rules covering package.json hygiene: sorting, schema validation, dependency restrictions, engines requirements, and no branch dependencies. Unlike generic JSON linters, it focuses on package.json-specific rules. Supports flat config (eslint.config.js) via processor configuration. Released as needed, maintained by Kelly Selden.","status":"active","version":"5.1.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/kellyselden/eslint-plugin-json-files","tags":["javascript","eslint","eslintplugin","eslint-plugin"],"install":[{"cmd":"npm install eslint-plugin-json-files","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-json-files","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-json-files","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required as the plugin runs within ESLint","package":"eslint","optional":false}],"imports":[{"note":"CommonJS require is supported. For ESM, use dynamic import or set package type to module with Node >=20.","symbol":"default (plugin object)","correct":"const jsonFiles = require('eslint-plugin-json-files');"},{"note":"Processor must be referenced as a string literal in the config.","symbol":"processor 'json-files/json'","correct":"processor: 'json-files/json'"},{"note":"Rule names must be prefixed with 'json-files/'","wrong":"rules: { 'sort-package-json': 'error' }","symbol":"rules (e.g., 'json-files/sort-package-json')","correct":"rules: { 'json-files/sort-package-json': 'error' }"}],"quickstart":{"code":"// eslint.config.js\nconst jsonFiles = require('eslint-plugin-json-files');\n\nmodule.exports = [\n  {\n    plugins: {\n      'json-files': jsonFiles,\n    },\n    processor: 'json-files/json',\n    rules: {\n      'json-files/sort-package-json': 'error',\n      'json-files/require-license': 'error',\n    },\n  },\n];","lang":"javascript","description":"Configures eslint-plugin-json-files in flat config with processor and two rules."},"warnings":[{"fix":"Migrate from .eslintrc to eslint.config.js using the flat config format shown in the quickstart.","message":"v5 drops support for legacy eslintrc config format; only flat config (eslint.config.js) is supported.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Upgrade Node.js to 20.9 or later.","message":"Node.js >=20.9 required starting from v5. Older Node versions will fail to load the plugin.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Add processor: 'json-files/json' in the flat config object.","message":"Processor must be explicitly set to 'json-files/json' for JSON file linting; omitting it results in no linting of JSON files.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Remove the rule from config or migrate to alternative validation.","message":"The rule 'json-files/ensure-repository-directory' is deprecated and will be removed in a future major version.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Add 'files' or 'ignores' in config to target specific JSON files.","message":"Rules only apply to package.json by default; other JSON files need explicit file matching via config.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install eslint eslint-plugin-json-files --save-dev'.","cause":"Plugin not installed or missing peer dependency 'eslint'.","error":"Error: Failed to load plugin 'eslint-plugin-json-files'"},{"fix":"Add 'processor: 'json-files/json'' to the config object.","cause":"Processor not configured in flat config.","error":"Error: Plugin 'eslint-plugin-json-files' uses processor but no processor was set"},{"fix":"Use dynamic import: 'import jsonFiles from 'eslint-plugin-json-files';' or set \"type\": \"commonjs\".","cause":"CommonJS require failing in ESM-only project.","error":"Error: Cannot find module 'eslint-plugin-json-files'"},{"fix":"Use 'json-files/sort-package-json' instead of 'sort-package-json'.","cause":"Rule name missing the 'json-files/' prefix.","error":"Rule 'json-files/sort-package-json' is not configured correctly"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}