{"id":19813,"library":"eslint-plugin-jsonc","title":"eslint-plugin-jsonc","description":"ESLint plugin for linting JSON, JSONC, and JSON5 files using ESLint rules and custom rules. Current stable version is 3.1.2 with frequent releases (multiple releases per year). The plugin parses JSON files with a custom parser (jsonc-eslint-parser) based on acorn, and provides 50+ rules including auto-fix for style issues. Key differentiators vs alternatives: supports JSONC and JSON5 syntax (comments, trailing commas, etc.), integrates with Vue SFC custom blocks, has more rules than @eslint/json, and supports ESLint directives. Since v3.0.0, the plugin exports a `languages` object for ESLint language plugin integration. Requires Node >=20.19 and ESLint >=9.38.0.","status":"active","version":"3.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/ota-meshi/eslint-plugin-jsonc","tags":["javascript","eslint","eslintplugin","eslint-plugin","lint","jsonc","json5","json"],"install":[{"cmd":"npm install eslint-plugin-jsonc","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-jsonc","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-jsonc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to run the plugin","package":"eslint","optional":true}],"imports":[{"note":"Default export for flat config (ESM). For CommonJS, use `require('eslint-plugin-jsonc')` or dynamic import.","wrong":"const plugin = require('eslint-plugin-jsonc')","symbol":"plugin","correct":"import plugin from 'eslint-plugin-jsonc'"},{"note":"Available since v3.0.0. Provides language objects for json, jsonc, json5, and x.","symbol":"languages","correct":"import { languages } from 'eslint-plugin-jsonc'"},{"note":"Access predefined configs like configs.recommended, configs['recommended-with-jsonc'], etc.","symbol":"configs","correct":"import { configs } from 'eslint-plugin-jsonc'"},{"note":"Access individual rules for custom configs.","symbol":"rules","correct":"import { rules } from 'eslint-plugin-jsonc'"}],"quickstart":{"code":"// eslint.config.js\nimport plugin from 'eslint-plugin-jsonc';\n\nexport default [\n  {\n    files: ['**/*.json'],\n    language: 'json/json',\n    plugins: { jsonc: plugin },\n    rules: {\n      'jsonc/no-comments': 'error',\n      'jsonc/sort-keys': 'error',\n    },\n  },\n  {\n    files: ['**/*.json5'],\n    language: 'json/json5',\n    plugins: { jsonc: plugin },\n    rules: {\n      'jsonc/valid-json-number': 'error',\n      'jsonc/auto': 'warn',\n    },\n  },\n];","lang":"javascript","description":"Configure ESLint flat config for JSON and JSON5 files using eslint-plugin-jsonc."},"warnings":[{"fix":"Use `language: 'json/json'` etc. in flat config. See documentation for migration.","message":"Since v3.0.0, the plugin exports a `languages` object. Configs using `language` must be used instead of the legacy `parser` and `processor` settings.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Upgrade ESLint to >=9.38.0 and Node to >=20.19.","message":"v3.0.0 dropped support for ESLint <9.38.0. The plugin now requires ESLint >=9.38.0 and Node >=20.19.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Migrate to flat config (eslint.config.js). You can use the `configs` export for predefined configs.","message":"The legacy config format (eslintrc) is deprecated. v3.0.0 heavily favors flat config.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Set `language: 'json/json'` or appropriate language in the flat config object.","message":"Using the plugin without setting the correct `language` will not lint JSON files correctly. The default language is JavaScript, so JSON-specific rules won't apply.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"If upgrading from v2, use the `languages` export and set `language` in flat config.","message":"v2.x and v3.x have major differences in configuration. The exported `languages` object was added in v3.0.0.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure the language supports comments: use `json/jsonc` or `json/json5` as appropriate.","message":"Some rules like `jsonc/no-comments` require a language that supports comments (jsonc or json5). Using it with `json/json` will cause parsing errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Upgrade ESLint to >=9.38.0 and ensure the import of eslint-plugin-jsonc is correct: `import plugin from 'eslint-plugin-jsonc'` and use `plugins: { jsonc: plugin }`.","cause":"Using `language` in flat config but ESLint version is <9.38.0 or the plugin's language plugins are not loaded correctly.","error":"Error: ESLint configuration in eslint.config.js is invalid: - Unexpected top-level property 'language'."},{"fix":"Set `language: 'json/jsonc'` for files with comments.","cause":"Attempting to lint a JSONC file (with comments) using the standard `json/json` language which does not allow comments.","error":"Parsing error: Unexpected token /"},{"fix":"Run `npm install eslint-plugin-jsonc --save-dev` and ensure the import is correct (e.g., `import plugin from 'eslint-plugin-jsonc'`).","cause":"Missing the package or using incorrect import path.","error":"Cannot find module 'eslint-plugin-jsonc'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}