Registry / testing / eslint-plugin-json-format

eslint-plugin-json-format

JSON →
library2.0.1jsnpmunverified

An ESLint plugin to lint, format, auto-fix, and sort JSON files. Version 2.0.1 is the latest stable release (last updated September 2019). It extends ESLint's capabilities to handle .json and rc files (like .eslintrc, .babelrc) with auto-fix support. Key differentiators include built-in package.json sorting (standard/pro/custom order), ignoring JSON-with-comments files like tsconfig.json, and ignoring package-lock.json by default. Requires ESLint >= 3.2.1. The plugin is in maintenance mode with no recent updates.

npm install eslint-plugin-json-format
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-JSON
E
eslint-plugin-json-format
testingjavascriptv2.0.1
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
plugins: ['json-format']
plugins: ['eslint-plugin-json-format']
ESLint automatically prefixes 'eslint-plugin-', so use 'json-format' in plugins array.
settings
settings: { 'json/sort-package-json': 'standard' }
settings: { json/sort-package-json: 'standard' }
The setting key must be quoted because it contains a slash. Also, 'sort-package-json' was renamed from 'package-json-sort-order' in v2.0.0.
rules
rules: { 'json-format/*': 'error' }
rules: { 'json/*': 'error' }
Rule names are prefixed with 'json-format/' (e.g., 'json-format/sort-package-json', 'json-format/json-format').

Install ESLint and the plugin, create a minimal .eslintrc.json configuration, and run ESLint with --fix on JSON files to auto-format and sort.

npm install eslint --save-dev npm install eslint-plugin-json-format --save-dev echo '{"plugins":["json-format"],"settings":{"json/sort-package-json":"standard","json/ignore-files":["**/package-lock.json"],"json/json-with-comments-files":["**/tsconfig.json",".vscode/**"]}}' > .eslintrc.json echo '{"name":"test","version":"1.0.0","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"license":"ISC"}' > package.json eslint --ext .js,.json,.eslintrc,.babelrc --fix .
Debug
Known issues
breakingIn v2.0.0, the setting 'package-json-sort-order' was renamed to 'sort-package-json'.
fix
Use 'json/sort-package-json' instead of 'json/package-json-sort-order'.
affects: <2.0.0
breakingThe 'sort-package-json' setting now expects a string ('standard', 'pro', false) or an array. Previously it accepted a different format.
fix
Update your configuration to match the new schema (e.g., 'json/sort-package-json': 'standard').
affects: <2.0.0
gotchaThe plugin will strip comments from files listed in 'json-with-comments-files' (like tsconfig.json) if linted with --fix.
fix
Do not include files that require comments (e.g., .vscode/settings.json) in 'json-with-comments-files', or disable auto-fix for those files.
affects: all
gotchaTo lint hidden files (e.g., .eslintrc.json), you must explicitly include them using a .eslintignore or the --ext flag with explicit names.
fix
Add '!.*' to .eslintignore or use 'eslint --ext .js,.json input/.eslintrc.json'.
affects: all
deprecatedThe plugin is no longer actively maintained; last release was in 2019.
fix
Consider alternatives like eslint-plugin-json or eslin-plugin-jsonc for newer ESLint versions.
affects: >=2.0.1
Errors
Common errors & fixes
Cannot read property 'getFilename' of undefined
ESLint version mismatch: plugin requires ESLint >= 3.2.1, but used with an older version.
fix
Update ESLint to version >=3.2.1: npm install eslint@latest --save-dev
Configuration for rule "json-format/json-format" is invalid
Trying to configure a rule that does not exist or using incorrect rule name prefix.
fix
Use 'json-format/sort-package-json' or 'json-format/*' wildcard, not 'json-format/json-format'. Example: 'rules': { 'json-format/*': 'error' }
ESLint couldn't find the plugin "eslint-plugin-json-format"
Plugin not installed or not listed in package.json dependencies.
fix
Run 'npm install eslint-plugin-json-format --save-dev' and ensure your ESLint config file is in the project root.
Unexpected token / in JSON at position 0
Plugin tried to parse a JSON file with comments (JSONC) without explicit configuration.
fix
Add the file pattern to 'json/json-with-comments-files' setting or remove comments from the file.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
eslintrequiredPeer dependency; required to load and use the plugin.
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-json-format — npm install eslint-plugin-json-format · libregistry