Registry / testing / eslint-plugin-jsonc

eslint-plugin-jsonc

JSON →
library3.1.2jsnpmunverified

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.

npm install eslint-plugin-jsonc
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-JSON
E
eslint-plugin-jsonc
testingjavascriptv3.1.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

plugin
✓ import plugin from 'eslint-plugin-jsonc'
✗ const plugin = require('eslint-plugin-jsonc')
Default export for flat config (ESM). For CommonJS, use `require('eslint-plugin-jsonc')` or dynamic import.
languages
✓ import { languages } from 'eslint-plugin-jsonc'
Available since v3.0.0. Provides language objects for json, jsonc, json5, and x.
configs
✓ import { configs } from 'eslint-plugin-jsonc'
Access predefined configs like configs.recommended, configs['recommended-with-jsonc'], etc.
rules
✓ import { rules } from 'eslint-plugin-jsonc'
Access individual rules for custom configs.

Configure ESLint flat config for JSON and JSON5 files using eslint-plugin-jsonc.

// eslint.config.js import plugin from 'eslint-plugin-jsonc'; export default [ { files: ['**/*.json'], language: 'json/json', plugins: { jsonc: plugin }, rules: { 'jsonc/no-comments': 'error', 'jsonc/sort-keys': 'error', }, }, { files: ['**/*.json5'], language: 'json/json5', plugins: { jsonc: plugin }, rules: { 'jsonc/valid-json-number': 'error', 'jsonc/auto': 'warn', }, }, ];
Debug
Known issues
gotchaSince v3.0.0, the plugin exports a `languages` object. Configs using `language` must be used instead of the legacy `parser` and `processor` settings.
fix
Use `language: 'json/json'` etc. in flat config. See documentation for migration.
affects: >=3.0.0
breakingv3.0.0 dropped support for ESLint <9.38.0. The plugin now requires ESLint >=9.38.0 and Node >=20.19.
fix
Upgrade ESLint to >=9.38.0 and Node to >=20.19.
affects: >=3.0.0
deprecatedThe legacy config format (eslintrc) is deprecated. v3.0.0 heavily favors flat config.
fix
Migrate to flat config (eslint.config.js). You can use the `configs` export for predefined configs.
affects: >=3.0.0
gotchaUsing 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.
fix
Set `language: 'json/json'` or appropriate language in the flat config object.
affects: >=3.0.0
breakingv2.x and v3.x have major differences in configuration. The exported `languages` object was added in v3.0.0.
fix
If upgrading from v2, use the `languages` export and set `language` in flat config.
affects: >=3.0.0
gotchaSome rules like `jsonc/no-comments` require a language that supports comments (jsonc or json5). Using it with `json/json` will cause parsing errors.
fix
Ensure the language supports comments: use `json/jsonc` or `json/json5` as appropriate.
affects: all
Errors
Common errors & fixes
Error: ESLint configuration in eslint.config.js is invalid: - Unexpected top-level property 'language'.
Using `language` in flat config but ESLint version is <9.38.0 or the plugin's language plugins are not loaded correctly.
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 }`.
Parsing error: Unexpected token /
Attempting to lint a JSONC file (with comments) using the standard `json/json` language which does not allow comments.
fix
Set `language: 'json/jsonc'` for files with comments.
Cannot find module 'eslint-plugin-jsonc'
Missing the package or using incorrect import path.
fix
Run `npm install eslint-plugin-jsonc --save-dev` and ensure the import is correct (e.g., `import plugin from 'eslint-plugin-jsonc'`).
Upgrade
Version history
3.1.2latest on npm
Audit
Dependencies
eslintoptionalpeer dependency required to run the plugin
Agent activity
11 hits · last 30 days
node
10
Resources
eslint-plugin-jsonc — npm install eslint-plugin-jsonc · libregistry