版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1 год назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # jsonc-eslint-parser
  2. [![NPM license](https://img.shields.io/npm/l/jsonc-eslint-parser.svg)](https://www.npmjs.com/package/jsonc-eslint-parser)
  3. [![NPM version](https://img.shields.io/npm/v/jsonc-eslint-parser.svg)](https://www.npmjs.com/package/jsonc-eslint-parser)
  4. [![NPM downloads](https://img.shields.io/npm/dw/jsonc-eslint-parser.svg)](http://www.npmtrends.com/jsonc-eslint-parser)
  5. [![NPM downloads](https://img.shields.io/npm/dm/jsonc-eslint-parser.svg)](http://www.npmtrends.com/jsonc-eslint-parser)
  6. [![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)
  7. [![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)
  8. ## :name_badge: Introduction
  9. [JSON], [JSONC] and [JSON5] parser for use with [ESLint] plugins.
  10. This parser allows us to lint [JSON], [JSONC] and [JSON5] files.
  11. This parser and the rules of [eslint-plugin-jsonc] would catch some of the mistakes and code style violations.
  12. See [eslint-plugin-jsonc] for details.
  13. ## :cd: Installation
  14. ```bash
  15. npm i --save-dev jsonc-eslint-parser
  16. ```
  17. ## :book: Usage
  18. In your ESLint configuration file, set the `overrides` > `parser` property:
  19. ```json5
  20. {
  21. // ...
  22. // Add the following settings.
  23. "overrides": [
  24. {
  25. "files": ["*.json", "*.json5"], // Specify the extension or pattern you want to parse as JSON.
  26. "parser": "jsonc-eslint-parser", // Set this parser.
  27. },
  28. ],
  29. }
  30. ```
  31. ## :gear: Configuration
  32. The following additional configuration options are available by specifying them in [parserOptions](https://eslint.org/docs/user-guide/configuring#specifying-parser-options-1) in your ESLint configuration file.
  33. ```json5
  34. {
  35. // ...
  36. "overrides": [
  37. {
  38. "files": ["*.json", "*.json5"],
  39. "parser": "jsonc-eslint-parser",
  40. // Additional configuration options
  41. "parserOptions": {
  42. "jsonSyntax": "JSON5"
  43. }
  44. },
  45. ],
  46. }
  47. ```
  48. ### `parserOptions.jsonSyntax`
  49. Set to `"JSON"`, `"JSONC"` or `"JSON5"`. Select the JSON syntax you are using.
  50. If not specified, all syntaxes that express static values ​​are accepted. For example, template literals without interpolation.
  51. **Note** : Recommended to loosen the syntax checking by the parser and use check rules of [eslint-plugin-jsonc] to automatically fix it.
  52. ## Usage for Custom Rules / Plugins
  53. - [AST.md](./docs/AST.md) is AST specification.
  54. - [no-template-literals.ts](https://github.com/ota-meshi/eslint-plugin-jsonc/blob/master/lib/rules/no-template-literals.ts) is an example.
  55. - You can see the AST on the [Online DEMO](https://ota-meshi.github.io/jsonc-eslint-parser/).
  56. ## :traffic_light: Semantic Versioning Policy
  57. **jsonc-eslint-parser** follows [Semantic Versioning](http://semver.org/).
  58. ## :couple: Related Packages
  59. - [eslint-plugin-jsonc](https://github.com/ota-meshi/eslint-plugin-jsonc) ... ESLint plugin for JSON, JSON with comments (JSONC) and JSON5.
  60. - [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) ... ESLint plugin for YAML.
  61. - [eslint-plugin-toml](https://github.com/ota-meshi/eslint-plugin-toml) ... ESLint plugin for TOML.
  62. - [eslint-plugin-json-schema-validator](https://github.com/ota-meshi/eslint-plugin-json-schema-validator) ... ESLint plugin that validates data using JSON Schema Validator.
  63. - [yaml-eslint-parser](https://github.com/ota-meshi/yaml-eslint-parser) ... YAML parser for use with ESLint plugins.
  64. - [toml-eslint-parser](https://github.com/ota-meshi/toml-eslint-parser) ... TOML parser for use with ESLint plugins.
  65. ## :lock: License
  66. See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
  67. [JSON]: https://json.org/
  68. [JSONC]: https://github.com/microsoft/node-jsonc-parser
  69. [JSON5]: https://json5.org/
  70. [ESLint]: https://eslint.org/
  71. [eslint-plugin-jsonc]: https://www.npmjs.com/package/eslint-plugin-jsonc