{"name":"jsonc-eslint-parser","version":"3.2.0","keywords":["eslint","json","jsonc","json5","parser"],"author":{"name":"Yosuke Ota"},"license":"MIT","_id":"jsonc-eslint-parser@3.2.0","maintainers":[{"name":"jounqin","email":"admin@1stg.me"},{"name":"ota-meshi","email":"otameshiyo23@gmail.com"}],"homepage":"https://github.com/ota-meshi/jsonc-eslint-parser#readme","bugs":{"url":"https://github.com/ota-meshi/jsonc-eslint-parser/issues"},"dist":{"shasum":"3b6094722123a8f27c692bed9250bf50767513c0","tarball":"http://registry-npm.ywwl.com/jsonc-eslint-parser/download/jsonc-eslint-parser-3.2.0.tgz","fileCount":6,"integrity":"sha512-fjACeZ2chy9tiBakt5nU5SZhzk385pkSSfmhVvS13o4gqGiHVCNJXTNve8kqMeKv7A0L50mdaNUb7T8s+Egrnw==","signatures":[{"sig":"MEYCIQDDbJzD/6y4J46LDEQ72GuD7ZeVLjJLRbKa84Di4wwEvgIhAIwGk8gJARjvLmkfKNESWwEBJTs1+kIK8ARaluWP9Uq1","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQC0LEyZUnsYy09p8d7f6HLDRC1ILw1Cvx5UtAFELejD/QIgVDvB5elp4NZowvf73K+25SDK6rLj3xl50wcPGlLaYz0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/jsonc-eslint-parser@3.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":60335,"size":14351,"noattachment":false,"key":"/jsonc-eslint-parser/-/jsonc-eslint-parser-3.2.0.tgz"},"type":"module","types":"lib/index.d.mts","engines":{"node":"^20.19.0 || ^22.13.0 || >=24"},"exports":{".":{"types":"./lib/index.d.mts","default":"./lib/index.mjs"},"./package.json":"./package.json"},"funding":"https://github.com/sponsors/ota-meshi","gitHead":"0b6e19fc272e073e9b0dfb3b4c2259f345251057","scripts":{"tsc":"tsc --noEmit","lint":"npm run eslint && npm run tsc","test":"npm run test:base","build":"npm run build:bundle","clean":"rimraf .nyc_output lib coverage","eslint":"eslint .","update":"tsx ./tools/update.ts && npm run eslint-fix && npm run test:nyc","release":"changeset publish","version":"npm run eslint-fix && git add .","test:nyc":"nyc --reporter=lcov npm run test:base","benchmark":"tsx benchmark/index.ts","test:base":"mocha --require tsx \"tests/src/**/*.ts\" --reporter dot --timeout 60000","eslint-fix":"eslint . --fix","prerelease":"npm run clean && npm run build","preversion":"npm test && npm run update && git add .","test:debug":"node --experimental-strip-types ./node_modules/mocha/bin/mocha.js \"tests/src/**/*.ts\" --reporter dot","version:ci":"changeset version","build:bundle":"tsdown","update-fixtures":"tsx ./tools/update-fixtures.ts"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:bb06c523-7f05-4f10-b344-778587ebd657"}},"repository":{"url":"git+https://github.com/ota-meshi/jsonc-eslint-parser.git","type":"git"},"_npmVersion":"11.16.0","description":"JSON, JSONC and JSON5 parser for use with ESLint plugins","directories":{},"_nodeVersion":"24.18.0","dependencies":{"acorn":"^8.5.0","verkit":"^0.3.2","eslint-visitor-keys":"^5.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^18.0.0","tsx":"^4.21.0","mocha":"^11.0.0","eslint":"^10.0.0","tsdown":"^0.22.0","env-cmd":"^11.0.0","prettier":"~3.8.0","benchmark":"^2.1.4","typescript":"~5.9.0","@types/node":"^24.0.0","@types/mocha":"^10.0.0","@types/estree":"^1.0.0","@changesets/cli":"^2.24.2","eslint-plugin-n":"^17.0.0","@types/benchmark":"^2.1.0","eslint-plugin-vue":"^10.0.0","typescript-eslint":"^8.0.0","vue-eslint-parser":"^10.0.0","eslint-plugin-jsdoc":"^62.0.0","eslint-plugin-jsonc":"^3.0.0","eslint-plugin-regexp":"^3.0.0","eslint-config-prettier":"^10.0.0","eslint-plugin-prettier":"^5.0.0","@ota-meshi/eslint-plugin":"^0.20.0","@typescript-eslint/parser":"^8.0.0","@changesets/changelog-github":"^0.7.0","eslint-plugin-node-dependencies":"^2.0.0","@typescript-eslint/eslint-plugin":"^8.0.0","eslint-plugin-json-schema-validator":"^6.0.0","@eslint-community/eslint-plugin-eslint-comments":"^4.3.0"},"_npmOperationalInternal":{"tmp":"tmp/jsonc-eslint-parser_3.2.0_1785902180479_0.3848568273569206","host":"s3://npm-registry-packages-npm-production"},"readme":"# jsonc-eslint-parser\n\n[![NPM license](https://img.shields.io/npm/l/jsonc-eslint-parser.svg)](https://www.npmjs.com/package/jsonc-eslint-parser)\n[![NPM version](https://img.shields.io/npm/v/jsonc-eslint-parser.svg)](https://www.npmjs.com/package/jsonc-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dw/jsonc-eslint-parser.svg)](http://www.npmtrends.com/jsonc-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dm/jsonc-eslint-parser.svg)](http://www.npmtrends.com/jsonc-eslint-parser)\n[![Build Status](https://github.com/ota-meshi/jsonc-eslint-parser/workflows/CI/badge.svg?branch=master)](https://github.com/ota-meshi/jsonc-eslint-parser/actions?query=workflow%3ACI)\n[![Coverage Status](https://coveralls.io/repos/github/ota-meshi/jsonc-eslint-parser/badge.svg?branch=master)](https://coveralls.io/github/ota-meshi/jsonc-eslint-parser?branch=master)\n\n## :name_badge: Introduction\n\n[JSON], [JSONC] and [JSON5] parser for use with [ESLint] plugins.\n\nThis parser allows us to lint [JSON], [JSONC] and [JSON5] files.\nThis parser and the rules of [eslint-plugin-jsonc] would catch some of the mistakes and code style violations.\n\nSee [eslint-plugin-jsonc] for details.\n\n## :cd: Installation\n\n```bash\nnpm i --save-dev jsonc-eslint-parser\n```\n\n## :book: Usage (Flat Config)\n\nIn your ESLint configuration file, set the `parser` property:\n\n```js\nimport * as jsoncParser from \"jsonc-eslint-parser\";\n\nexport default [\n  {\n    // ...\n    // Add the following settings.\n    files: [\"**/*.json\", \"**/*.json5\"], // Specify the extension or pattern you want to parse as JSON.\n    languageOptions: {\n      parser: jsoncParser, // Set this parser.\n    }\n  },\n];\n```\n\n## :book: Usage (Legacy Config)\n\nIn your ESLint configuration file, set the `overrides` > `parser` property:\n\n```json5\n{\n  // ...\n  // Add the following settings.\n  \"overrides\": [\n    {\n      \"files\": [\"*.json\", \"*.json5\"], // Specify the extension or pattern you want to parse as JSON.\n      \"parser\": \"jsonc-eslint-parser\", // Set this parser.\n    },\n  ],\n}\n```\n\n## :gear: Configuration\n\nThe following additional configuration options are available by specifying them in [parserOptions](https://eslint.org/docs/latest/use/configure/parser#configure-parser-options) in your ESLint configuration file.\n\n```json5\n{\n  // Additional configuration options\n  \"parserOptions\": {\n    \"jsonSyntax\": \"JSON5\"\n  }\n}\n```\n\n### `parserOptions.jsonSyntax`\n\nSet to `\"JSON\"`, `\"JSONC\"` or `\"JSON5\"`. Select the JSON syntax you are using.  \nIf not specified, all syntaxes that express static values ​​are accepted. For example, template literals without interpolation.  \n\n**Note** : Recommended to loosen the syntax checking by the parser and use check rules of [eslint-plugin-jsonc] to automatically fix it.\n\n## :gear: API\n\n### `parseJSON(code, options?)`\n\nParses the given JSON source code and returns the AST.\n\n```js\nimport { parseJSON } from \"jsonc-eslint-parser\";\n\nconst ast = parseJSON('{\"key\": \"value\"}', { jsonSyntax: \"JSON\" });\nconsole.log(ast);\n```\n\n**Parameters:**\n\n- `code` (string): The JSON source code to parse.\n- `options` (object, optional): Parser options.\n  - `jsonSyntax` (`\"JSON\"` | `\"JSONC\"` | `\"JSON5\"`): The JSON syntax to use.\n\n**Returns:** `JSONProgram` - The root AST node.\n\n### `parseForESLint(code, options?)`\n\nParses the given JSON source code for ESLint. This is the main parser function used by ESLint.\n\n```js\nimport { parseForESLint } from \"jsonc-eslint-parser\";\n\nconst result = parseForESLint('{\"key\": \"value\"}', { jsonSyntax: \"JSON\" });\nconsole.log(result.ast);\nconsole.log(result.services);\nconsole.log(result.visitorKeys);\n```\n\n**Parameters:**\n\n- `code` (string): The JSON source code to parse.\n- `options` (object, optional): Parser options (same as `parseJSON`).\n\n**Returns:** An object containing:\n\n- `ast`: The root AST node.\n- `services`: An object with helper methods like `getStaticJSONValue()`.\n- `visitorKeys`: Visitor keys for traversing the AST.\n\n### `tokenize(code, options?)`\n\nTokenizes the given JSON source code and returns an array of tokens.\n\n```js\nimport { tokenize } from \"jsonc-eslint-parser\";\n\nconst tokens = tokenize('{\"key\": \"value\"}', { jsonSyntax: \"JSON\" });\nconsole.log(tokens);\n// [\n//   { type: 'Punctuator', value: '{', range: [0, 1], loc: {...} },\n//   { type: 'String', value: '\"key\"', range: [1, 6], loc: {...} },\n//   { type: 'Punctuator', value: ':', range: [6, 7], loc: {...} },\n//   { type: 'String', value: '\"value\"', range: [8, 15], loc: {...} },\n//   { type: 'Punctuator', value: '}', range: [15, 16], loc: {...} }\n// ]\n\n// Include comments in the result\nconst tokensWithComments = tokenize('{\"key\": \"value\" /* comment */}', {\n  jsonSyntax: \"JSONC\",\n  includeComments: true\n});\n```\n\n**Parameters:**\n\n- `code` (string): The JSON source code to tokenize.\n- `options` (object, optional): Parser options.\n  - `jsonSyntax` (`\"JSON\"` | `\"JSONC\"` | `\"JSON5\"`): The JSON syntax to use.\n  - `includeComments` (boolean): If `true`, comments are included in the result array.\n\n**Returns:** `Token[]` or `(Token | Comment)[]` - An array of tokens, optionally including comments.\n\n## Usage for Custom Rules / Plugins\n\n- [AST.md](./docs/AST.md) is AST specification.\n- [Plugins.md](./docs/Plugins.md) describes using this in an ESLint plugin.\n- [no-template-literals.ts](https://github.com/ota-meshi/eslint-plugin-jsonc/blob/master/lib/rules/no-template-literals.ts) is an example.\n- You can see the AST on the [Online DEMO](https://ota-meshi.github.io/jsonc-eslint-parser/).\n\n## :traffic_light: Semantic Versioning Policy\n\n**jsonc-eslint-parser** follows [Semantic Versioning](http://semver.org/).\n\n## :couple: Related Packages\n\n- [eslint-plugin-jsonc](https://github.com/ota-meshi/eslint-plugin-jsonc) ... ESLint plugin for JSON, JSON with comments (JSONC) and JSON5.\n- [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) ... ESLint plugin for YAML.\n- [eslint-plugin-toml](https://github.com/ota-meshi/eslint-plugin-toml) ... ESLint plugin for TOML.\n- [eslint-plugin-json-schema-validator](https://github.com/ota-meshi/eslint-plugin-json-schema-validator) ... ESLint plugin that validates data using JSON Schema Validator.\n- [yaml-eslint-parser](https://github.com/ota-meshi/yaml-eslint-parser) ... YAML parser for use with ESLint plugins.\n- [toml-eslint-parser](https://github.com/ota-meshi/toml-eslint-parser) ... TOML parser for use with ESLint plugins.\n\n## :lock: License\n\nSee the [LICENSE](LICENSE) file for license rights and limitations (MIT).\n\n[JSON]: https://json.org/\n[JSONC]: https://github.com/microsoft/node-jsonc-parser\n[JSON5]: https://json5.org/\n[ESLint]: https://eslint.org/\n[eslint-plugin-jsonc]: https://www.npmjs.com/package/eslint-plugin-jsonc\n","publish_time":1785902180562,"_cnpm_publish_time":1785902180562,"dist-tags":{"latest":"3.3.0"}}