{"name":"jsonc-eslint-parser","version":"2.4.1","keywords":["eslint","json","jsonc","json5","parser"],"author":{"name":"Yosuke Ota"},"license":"MIT","_id":"jsonc-eslint-parser@2.4.1","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":"64a8ed77311d33ac450725c1a438132dd87b2b3b","tarball":"http://registry-npm.ywwl.com/jsonc-eslint-parser/download/jsonc-eslint-parser-2.4.1.tgz","fileCount":39,"integrity":"sha512-uuPNLJkKN8NXAlZlQ6kmUF9qO+T6Kyd7oV4+/7yy8Jz6+MZNyhPq8EdLpdfnPVzUC8qSf1b4j1azKaGnFsjmsw==","signatures":[{"sig":"MEQCIF/VAByi0GHwQSPSFUyP0FFN87bfwfSiifdXP0bD7UlfAiAw25ZLs9Ca1ph1ZLsVO4DoBa45mHGPpw8enO+ICTwfWA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":78406,"size":16890,"noattachment":false,"key":"/jsonc-eslint-parser/-/jsonc-eslint-parser-2.4.1.tgz"},"main":"lib/index.js","types":"./lib/index.d.ts","engines":{"node":"^12.22.0 || ^14.17.0 || >=16.0.0"},"funding":"https://github.com/sponsors/ota-meshi","gitHead":"e33d24cd65bef493bcc52b659810c33372246a44","scripts":{"lint":"eslint . --ext .js,.ts,.json","test":"npm run test:base","build":"npm run build:meta && npm run build:tsc","clean":"rimraf .nyc_output lib coverage","update":"ts-node ./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":"ts-node --transpile-only benchmark/index.ts","build:tsc":"tsc --project ./tsconfig.build.json","test:base":"mocha --require ts-node/register \"tests/src/**/*.ts\" --reporter dot --timeout 60000","build:meta":"ts-node --transpile-only ./tools/update-meta.ts","eslint-fix":"eslint . --ext .js,.ts,.json --fix","prerelease":"npm run clean && npm run build","preversion":"npm test && npm run update && git add .","test:debug":"mocha --require ts-node/register/transpile-only \"tests/src/**/*.ts\" --reporter dot","version:ci":"env-cmd -e version-ci -- npm run build:meta && changeset version","update-fixtures":"ts-node ./tools/update-fixtures.ts"},"_npmUser":{"name":"ota-meshi","email":"otameshiyo23@gmail.com"},"repository":{"url":"git+https://github.com/ota-meshi/jsonc-eslint-parser.git","type":"git"},"_npmVersion":"10.8.2","description":"JSON, JSONC and JSON5 parser for use with ESLint plugins","directories":{},"_nodeVersion":"20.19.5","dependencies":{"acorn":"^8.5.0","espree":"^9.0.0","semver":"^7.3.5","eslint-visitor-keys":"^3.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^17.0.0","mocha":"^10.0.0","eslint":"^8.0.0","env-cmd":"^11.0.0","ts-node":"^10.0.0","prettier":"~3.6.0","benchmark":"^2.1.4","typescript":"~5.0.0","@types/node":"^22.0.0","@types/mocha":"^10.0.0","@types/eslint":"^9.0.0","@types/estree":"^1.0.0","@types/semver":"^7.3.1","@changesets/cli":"^2.24.2","eslint-plugin-n":"^17.0.0","@types/benchmark":"^2.1.0","eslint-plugin-vue":"^9.0.0","vue-eslint-parser":"^10.0.0","eslint-plugin-jsonc":"^2.0.0","eslint-plugin-regexp":"^2.0.0","@types/natural-compare":"^1.4.0","eslint-config-prettier":"^10.0.0","eslint-plugin-prettier":"^5.0.0","@ota-meshi/eslint-plugin":"^0.15.0","@typescript-eslint/parser":"^8.0.0","@types/eslint-visitor-keys":"^3.0.0","@changesets/changelog-github":"^0.5.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-node-dependencies":"^1.0.0","@typescript-eslint/eslint-plugin":"^8.0.0","eslint-plugin-json-schema-validator":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/jsonc-eslint-parser_2.4.1_1758425348129_0.8702938487100211","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":1758425348325,"_cnpm_publish_time":1758425348325,"dist-tags":{"latest":"3.3.0"}}