- You can use ESLint to lint JSON.
"jsonc/auto"rule provided by this plugin.
- You can choose the appropriate config provided by this plugin depending on whether you are using JSON, JSONC or JSON5.
- Supports Vue SFC custom blocks such as
vue-eslint-parserv7.3.0 and above.
- Supports ESLint directives. e.g.
- You can check your code in real-time using the ESLint editor integrations.
You can check on the Online DEMO.
❓ Why is it ESLint plugin?
This plugin parses
.json with its own parser, but this parser just converts AST parsed by
acorn (It is used internally by the ESLint standard parser) into AST with another name. However, ASTs that do not exist in JSON and the superset of JSON syntaxes are reported as parsing errors. By converting the AST to another name, we prevent false positives from ESLint core rules.
Moreover, You can do the same linting using the extended rules of the ESLint core rules provided by this plugin.
The parser package used by this plugin is jsonc-eslint-parser.
❓ How is it different from other JSON plugins?
Plugins that do not use AST
These plugins use the processor to parse and return the results independently, without providing the ESLint engine with AST and source code text.
Plugins don't provide AST, so you can't use directive comments (e.g.
/* eslint-disable */).
Plugins don't provide source code text, so you can't use it with plugins and rules that use text (e.g. eslint-plugin-prettier, eol-last).
Also, most plugins don't support JSON5.
eslint-plugin-jsonc works by providing AST and source code text to ESLint.
1 + 1,
(42)). Also, ESLint core rules and other plugin rules can false positives (e.g. quote-props rule reports quote on keys), which can complicate the your configuration.
See User Guide.
See Available Rules.
🚀 To Do More Verification
Verify using JSON Schema
You can verify using JSON Schema by checking and installing eslint-plugin-json-schema-validator.
You can verify the message files by checking and installing @intlify/eslint-plugin-vue-i18n.
👫 Related Packages
- eslint-plugin-yml ... ESLint plugin for YAML.
- eslint-plugin-toml ... ESLint plugin for TOML.
- eslint-plugin-json-schema-validator ... ESLint plugin that validates data using JSON Schema Validator.
- jsonc-eslint-parser ... JSON, JSONC and JSON5 parser for use with ESLint plugins.
- yaml-eslint-parser ... YAML parser for use with ESLint plugins.
- toml-eslint-parser ... TOML parser for use with ESLint plugins.
See the LICENSE file for license rights and limitations (MIT).