Skip to content

ota-meshi/jsonc-eslint-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1fe0d2e Β· Jun 10, 2024
Oct 24, 2023
May 8, 2024
Jan 22, 2024
Jul 14, 2023
Oct 24, 2023
May 24, 2024
Mar 23, 2024
Nov 16, 2023
Jul 14, 2023
Jul 14, 2023
May 9, 2023
Jul 3, 2021
Oct 24, 2023
Aug 14, 2020
Aug 14, 2020
Oct 24, 2023
Aug 14, 2020
Feb 22, 2024
Jun 10, 2024
Jul 1, 2022
Feb 26, 2021
Jul 1, 2022
Feb 22, 2024

Repository files navigation

jsonc-eslint-parser

NPM license NPM version NPM downloads NPM downloads Build Status Coverage Status

πŸ“› Introduction

JSON, JSONC and JSON5 parser for use with ESLint plugins.

This parser allows us to lint JSON, JSONC and JSON5 files. This parser and the rules of eslint-plugin-jsonc would catch some of the mistakes and code style violations.

See eslint-plugin-jsonc for details.

πŸ’Ώ Installation

npm i --save-dev jsonc-eslint-parser

πŸ“– Usage (Flat Config)

In your ESLint configuration file, set the parser property:

import jsoncParser from "jsonc-eslint-parser";

export default [
  {
    // ...
    // Add the following settings.
    files: ["*.json", "*.json5"], // Specify the extension or pattern you want to parse as JSON.
    languageOptions: {
      parser: jsoncParser, // Set this parser.
    }
  },
];

πŸ“– Usage (Legacy Config)

In your ESLint configuration file, set the overrides > parser property:

{
  // ...
  // Add the following settings.
  "overrides": [
    {
      "files": ["*.json", "*.json5"], // Specify the extension or pattern you want to parse as JSON.
      "parser": "jsonc-eslint-parser", // Set this parser.
    },
  ],
}

βš™οΈ Configuration

The following additional configuration options are available by specifying them in parserOptions in your ESLint configuration file.

{
  // ...
  "overrides": [
    {
      "files": ["*.json", "*.json5"],
      "parser": "jsonc-eslint-parser",
      // Additional configuration options
      "parserOptions": {
        "jsonSyntax": "JSON5"
      }
    },
  ],
}

parserOptions.jsonSyntax

Set to "JSON", "JSONC" or "JSON5". Select the JSON syntax you are using.
If not specified, all syntaxes that express static values ​​are accepted. For example, template literals without interpolation.

Note : Recommended to loosen the syntax checking by the parser and use check rules of eslint-plugin-jsonc to automatically fix it.

Usage for Custom Rules / Plugins

πŸš₯ Semantic Versioning Policy

jsonc-eslint-parser follows Semantic Versioning.

πŸ‘« Related Packages

πŸ”’ License

See the LICENSE file for license rights and limitations (MIT).