Registry / testing / eslint-plugin-json5

eslint-plugin-json5

JSON →
library0.1.4jsnpmunverified

An ESLint plugin providing a preprocessor to lint JSON5 files using standard ESLint rules for JavaScript objects. The plugin works by treating JSON5 files as JavaScript object literals, allowing all standard ESLint rules (e.g., no-undef, quotes) to apply. Current stable version is 0.1.4, with no major updates since 2020. It supports ESLint 3-8 via broad peer dependency range. Key differentiator: avoids writing separate JSON5-specific rules by reusing existing ESLint infrastructure. No TypeScript support, no monorepo integration, no file watching improvements. Last released May 2020.

npm install eslint-plugin-json5
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-JSON
E
eslint-plugin-json5
testingjavascriptv0.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

plugin
import json5 from 'eslint-plugin-json5'
const json5 = require('eslint-plugin-json5')
Plugin is a default export. CommonJS require works but may not be detected by some bundlers. Since the plugin ships a single default export, named import fails.
configs
const json5 = require('eslint-plugin-json5'); module.exports = { plugins: ['json5'], ... };
module.exports = { plugins: ['eslint-plugin-json5'] };
When using .eslintrc.js, the plugin string should be just 'json5', not the full package name. This is a common ESLint plugin gotcha.
processor
import { processors } from 'eslint-plugin-json5';
import json5 from 'eslint-plugin-json5'; const processors = json5.processors;
Named export 'processors' is available. Default export also has .processors property. Prefer named import for clarity.

Shows how to install and configure the plugin, then lint a JSON5 file with standard rules like no-undef and quotes.

// Ensure ESLint is installed locally // Install the plugin // npm install --save-dev eslint-plugin-json5 // .eslintrc.json { "plugins": ["json5"], "extends": ["eslint:recommended"], "rules": { "no-undef": "error", "quotes": ["error", "double"] } } // Run ESLint on JSON5 files // npx eslint . --ext json5 // Example .json5 file (config.json5) { // comment port: 8080, host: 'localhost', unquoted: true }
Debug
Known issues
gotchaThe plugin only processes JSON5 files; you must specify --ext json5 on the ESLint CLI.
fix
Use 'eslint . --ext json5' or configure overrides in eslintrc for json5 files.
affects: >=0.1.0
gotchaAll rules apply as if the JSON5 content is a JavaScript object literal, which can cause unintended errors like 'no-undef' on values.
fix
Disable conflicting rules for JSON5 files via overrides or adjust configuration.
affects: >=0.1.0
lostNo version has been released since 2020; there is no active maintenance or bug fixes.
fix
Consider alternatives like eslint-plugin-jsonc or directly parse JSON5 with your own scripts.
affects: 0.1.4
gotchaThe plugin adds a preprocessor that transforms the file's extension to .json, which may interfere with other file-type plugins.
fix
Ensure no other processor handles .json files with conflicting transformations.
affects: >=0.1.0
Errors
Common errors & fixes
Error: No configuration for .json5 files found. Make sure you add --ext json5 to your command.
ESLint does not automatically lint .json5 files without specifying the extension.
fix
Run 'eslint . --ext json5' or add 'overrides' in eslintrc for '*.json5' files.
Parsing error: Unexpected token /
JSON5 files contain comments, but the plugin expects valid JavaScript object literals (which it gets), but if the file is parsed as JSON by another tool, comments cause errors.
fix
Only use this plugin with ESLint; do not try to parse the file as JSON. Ensure the file is treated as .json5 and not .json.
Warning: The 'no-undef' rule found undefined variable 'someKey'
The processor treats the entire file as a JavaScript object, so keys that are not defined as global or local variables trigger no-undef.
fix
Disable 'no-undef' rule for JSON5 files in overrides, or add dummy globals.
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies
eslintrequiredPeer dependency required for plugin registration and rule processing.
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-json5 — npm install eslint-plugin-json5 · libregistry