@prantlf/jsonlint 12.0.0 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +407 -0
- package/README.md +9 -9
- package/lib/cli.js +6 -4
- package/lib/index.d.ts +10 -2
- package/lib/validator.js +45 -35
- package/package.json +11 -7
- package/web/ajv.min.js +7 -1
- package/web/ajv.min.js.map +1 -7
- package/web/jsonlint.html +23 -5
- package/web/validator.min.js +3 -3
- package/web/validator.min.js.map +3 -3
- package/lib/schema-drafts.js +0 -482
- package/web/ajv7.min.js +0 -8
- package/web/ajv7.min.js.map +0 -1
- package/web/schema-drafts.min.js +0 -2
- package/web/schema-drafts.min.js.map +0 -7
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
## [13.0.1](https://github.com/prantlf/jsonlint/compare/v13.0.0...v13.0.1) (2023-03-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Replace ajv@6 with ajv-draft-04 ([b1535a3](https://github.com/prantlf/jsonlint/commit/b1535a3ec24be7913f0005cdd617680c02086cdf))
|
|
7
|
+
|
|
8
|
+
# [13.0.0](https://github.com/prantlf/jsonlint/compare/v12.0.0...v13.0.0) (2023-03-05)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Support JSON Schema drafts 2019-09 and 2020-12 and JSON Type Definition ([0b9130c](https://github.com/prantlf/jsonlint/commit/0b9130ceae5f6f27cbe3e6d65207127862ffe584))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* The default environment recognises only JSON Schema drafts 06 and 07 automatically. Not 04 any more. The environment for JSON Schema drafts 04 has to be selected explicitly. Also, JSON Schema drafts 06 and 07 are handled by AJV@8 instead of AJV@6. It shouldn't make any difference, but the implementation is new and could perform a stricter validation.
|
|
19
|
+
|
|
20
|
+
# [12.0.0](https://github.com/prantlf/jsonlint/compare/v11.7.2...v12.0.0) (2023-03-05)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* Upgrade dependencies and require Node.js 14 ([87205c2](https://github.com/prantlf/jsonlint/commit/87205c2427a0ebe0d791a4189b2b2346506601b3))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### BREAKING CHANGES
|
|
29
|
+
|
|
30
|
+
* Dropped support for Node.js 12 . The minimum supported version is Node.js 14.
|
|
31
|
+
|
|
32
|
+
## [11.7.2](https://github.com/prantlf/jsonlint/compare/v11.7.1...v11.7.2) (2023-03-05)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* Use both typings and types in package.json ([5d00c00](https://github.com/prantlf/jsonlint/commit/5d00c00c7fd098674ee9d1f3dba14369debaa73b))
|
|
38
|
+
|
|
39
|
+
## [11.7.1](https://github.com/prantlf/jsonlint/compare/v11.7.0...v11.7.1) (2023-03-05)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* Complete TypeScript types ([7064c50](https://github.com/prantlf/jsonlint/commit/7064c5041a292a5a87bccc2de7fc945a2ee7c160))
|
|
45
|
+
|
|
46
|
+
# [11.7.0](https://github.com/prantlf/jsonlint/compare/v11.6.0...v11.7.0) (2022-09-26)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Bug Fixes
|
|
50
|
+
|
|
51
|
+
* Upgrade npm dependencies ([81526ce](https://github.com/prantlf/jsonlint/commit/81526ce034cf52623dbca986cf9d450287fb104a))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Features
|
|
55
|
+
|
|
56
|
+
* Ignore the leading UTF-8 byte-order mark (BOM) ([311c6df](https://github.com/prantlf/jsonlint/commit/311c6df75963a5b6da3984ba85541b800d751939))
|
|
57
|
+
|
|
58
|
+
# [11.6.0](https://github.com/prantlf/jsonlint/compare/v11.5.0...v11.6.0) (2022-05-04)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Bug Fixes
|
|
62
|
+
|
|
63
|
+
* Do not generate text diff if not needed ([0423a4b](https://github.com/prantlf/jsonlint/commit/0423a4b1fbc10cb6a201fe79e29a2b0e0101f3d0))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
* Allow setting the line count as diff context ([9b22843](https://github.com/prantlf/jsonlint/commit/9b22843a93ec47c0e18b1833618072083989b431))
|
|
69
|
+
|
|
70
|
+
# [11.5.0](https://github.com/prantlf/jsonlint/compare/v11.4.0...v11.5.0) (2022-05-03)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Bug Fixes
|
|
74
|
+
|
|
75
|
+
* Do not print file names twice in the compact mode ([86691cc](https://github.com/prantlf/jsonlint/commit/86691cc5fea760a437cae5aff71f0acc987c4e05))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### Features
|
|
79
|
+
|
|
80
|
+
* Add option "diff" to print the difference instead of the output ([cb3826c](https://github.com/prantlf/jsonlint/commit/cb3826c7610aae8d23623da3693e45cbf942223e))
|
|
81
|
+
|
|
82
|
+
# [11.4.0](https://github.com/prantlf/jsonlint/compare/v11.3.0...v11.4.0) (2022-05-03)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### Features
|
|
86
|
+
|
|
87
|
+
* Introduce a check that the formatted output is the same as the input ([75167f7](https://github.com/prantlf/jsonlint/commit/75167f76c4bbd13551ca7e20824cc05095fc6be0))
|
|
88
|
+
|
|
89
|
+
# [11.3.0](https://github.com/prantlf/jsonlint/compare/v11.2.0...v11.3.0) (2022-05-03)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### Bug Fixes
|
|
93
|
+
|
|
94
|
+
* Fix the regex splitting input by line breaks ([7423806](https://github.com/prantlf/jsonlint/commit/74238065643d31044990801713410041cdbb55f0))
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
### Features
|
|
98
|
+
|
|
99
|
+
* Read options from configuration files ([7eebd76](https://github.com/prantlf/jsonlint/commit/7eebd765f66bcd3bcd6cde7d9c128cbacaca1285))
|
|
100
|
+
|
|
101
|
+
# [11.2.0](https://github.com/prantlf/jsonlint/compare/v11.1.1...v11.2.0) (2022-05-01)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### Features
|
|
105
|
+
|
|
106
|
+
* Allow logging only the name of processed files ([91346d9](https://github.com/prantlf/jsonlint/commit/91346d95459f5b516ae71233050262534f197fbf))
|
|
107
|
+
* Allow to continue processing in case of error ([e5318eb](https://github.com/prantlf/jsonlint/commit/e5318ebb75f90459ff4164ec6e84efcc34a9bf4c))
|
|
108
|
+
* Support BASH patterns to specify input files ([31d162f](https://github.com/prantlf/jsonlint/commit/31d162fa9578bd6888d01c3cd0175960b5740d86))
|
|
109
|
+
|
|
110
|
+
## [11.1.1](https://github.com/prantlf/jsonlint/compare/v11.1.0...v11.1.1) (2022-05-01)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### Bug Fixes
|
|
114
|
+
|
|
115
|
+
* Retain the original last line break in the processed file ([54fd5ab](https://github.com/prantlf/jsonlint/commit/54fd5ab0349300c7bd11dfa6baf4e787e40bead9))
|
|
116
|
+
|
|
117
|
+
# [11.1.0](https://github.com/prantlf/jsonlint/compare/v11.0.0...v11.1.0) (2022-05-01)
|
|
118
|
+
|
|
119
|
+
### Bug Fixes
|
|
120
|
+
|
|
121
|
+
* Merge remote-tracking branch 'xmedeko/patch-1' ([da3e1dc](https://github.com/prantlf/jsonlint/commit/da3e1dca6ce6efcd8d5bd775d75bad06d8c46223))
|
|
122
|
+
|
|
123
|
+
### Features
|
|
124
|
+
|
|
125
|
+
* Optionally ensure a line break at the end of the output ([226019e](https://github.com/prantlf/jsonlint/commit/226019eb75c675eab1dca817ff0dc42e0223d197))
|
|
126
|
+
|
|
127
|
+
# [11.0.0](https://github.com/prantlf/jsonlint/compare/v10.2.0...v11.0.0) (2022-05-01)
|
|
128
|
+
|
|
129
|
+
### Bug Fixes
|
|
130
|
+
|
|
131
|
+
* Upgrade dependencies ([0d35969](https://github.com/prantlf/jsonlint/commit/0d359690aa19884a6d17990c476cf780b39663c0))
|
|
132
|
+
|
|
133
|
+
### BREAKING CHANGES
|
|
134
|
+
|
|
135
|
+
* The minimum supported version has become Node.js 12 instead of the previous Node.js 6. At least `commander` needs the new version.
|
|
136
|
+
|
|
137
|
+
# [10.2.0](https://github.com/prantlf/jsonlint/compare/v10.1.1...v10.2.0) (2019-12-28)
|
|
138
|
+
|
|
139
|
+
### Features
|
|
140
|
+
|
|
141
|
+
* Allow trimming trailing commas in arrays and objects (JSON5) ([136ea99](https://github.com/prantlf/jsonlint/commit/136ea995bef7b0f77c2ac54b6ce7dd8572190bf8))
|
|
142
|
+
* Allow unifying quotes around object keys to double or single ones (JSON5) ([6b6da17](https://github.com/prantlf/jsonlint/commit/6b6da175cfea8f71841e145a525ef124c19c2607))
|
|
143
|
+
|
|
144
|
+
# [10.1.1](https://github.com/prantlf/jsonlint/compare/v10.1.0...v10.1.1) (2019-12-27)
|
|
145
|
+
|
|
146
|
+
### Bug Fixes
|
|
147
|
+
|
|
148
|
+
* Restore compatibility with IE11 ([55b8a48](https://github.com/prantlf/jsonlint/commit/55b8a4816b08c5504cf7f0841d1997634a6376ea))
|
|
149
|
+
|
|
150
|
+
# [10.1.0](https://github.com/prantlf/jsonlint/compare/v10.0.2...v10.1.0) (2019-12-27)
|
|
151
|
+
|
|
152
|
+
### Features
|
|
153
|
+
|
|
154
|
+
* Alternatively accept number of spaces for the indent parameter ([4c25739](https://github.com/prantlf/jsonlint/commit/4c257399b77e446c198b25049fae2ca08ad174ec))
|
|
155
|
+
|
|
156
|
+
# [10.0.2](https://github.com/prantlf/jsonlint/compare/v10.0.1...v10.0.2) (2019-12-27)
|
|
157
|
+
|
|
158
|
+
### Bug Fixes
|
|
159
|
+
|
|
160
|
+
* Do not modify input options in the tokenize method ([7e3ac0b](https://github.com/prantlf/jsonlint/commit/7e3ac0babf873c42da1daadaee2bbe55d2644690))
|
|
161
|
+
|
|
162
|
+
# [10.0.1](https://github.com/prantlf/jsonlint/compare/v10.0.0...v10.0.1) (2019-12-27)
|
|
163
|
+
|
|
164
|
+
### Bug Fixes
|
|
165
|
+
|
|
166
|
+
* Pretty-printer: keep the comment after opening an object scope indented ([4fbc09d](https://github.com/prantlf/jsonlint/commit/4fbc09d402ed5442e2de77382342267e330cb908))
|
|
167
|
+
|
|
168
|
+
# [10.0.0](https://github.com/prantlf/jsonlint/compare/v9.0.0...v10.0.0) (2019-12-27)
|
|
169
|
+
|
|
170
|
+
### Bug Fixes
|
|
171
|
+
|
|
172
|
+
* Rename the property "exzerpt" in error information to "excerpt" ([4c74e3d](https://github.com/prantlf/jsonlint/commit/4c74e3d866fc54a7b2f833ff522efbaef3331bbe))
|
|
173
|
+
|
|
174
|
+
### Features
|
|
175
|
+
|
|
176
|
+
* Add support for pretty-printing of the JSON input ([d5eaa93](https://github.com/prantlf/jsonlint/commit/d5eaa9350d654050316b186dc8965ce9cb45d905))
|
|
177
|
+
|
|
178
|
+
### BREAKING CHANGES
|
|
179
|
+
|
|
180
|
+
* If you used the property "exzerpt" from the parsing error object, you have to change it to "excerpt". It should be easy using a full-text search in your sources.
|
|
181
|
+
* The option for pretty-printing *invalid input* has been renamed:
|
|
182
|
+
|
|
183
|
+
-p (--pretty-print) ==> -P (--pretty-print-invalid)
|
|
184
|
+
|
|
185
|
+
The option `-p (--pretty-print)` will newly prettify the raw (text) input instead of formatting the parsed JSON object.
|
|
186
|
+
|
|
187
|
+
# [9.0.0](https://github.com/prantlf/jsonlint/compare/v8.0.3...v9.0.0) (2019-12-22)
|
|
188
|
+
|
|
189
|
+
### chore
|
|
190
|
+
|
|
191
|
+
* Upgrade package dependencies ([4a8f2d9](https://github.com/prantlf/jsonlint/commit/4a8f2d9c27428da32b95f607bf7952190636af9f))
|
|
192
|
+
|
|
193
|
+
### Features
|
|
194
|
+
|
|
195
|
+
* Add TypeScript typings ([ba6c979](https://github.com/prantlf/jsonlint/commit/ba6c9790792837fdc3abd0032899ffd04953cf3d))
|
|
196
|
+
|
|
197
|
+
### BREAKING CHANGES
|
|
198
|
+
|
|
199
|
+
* Dependencies (commander, at least) dropped support for Node.js 4. Node.js 6 should still work, but officially it is not supported either. You should upgrade to the current or still supported Node.js LTS version.
|
|
200
|
+
|
|
201
|
+
## [8.0.3](https://github.com/prantlf/jsonlint/compare/v8.0.2...v8.0.3) (2019-09-24)
|
|
202
|
+
|
|
203
|
+
### Bug Fixes
|
|
204
|
+
|
|
205
|
+
* Upgrade package dependencies and adapt sources ([9f1f332](https://github.com/prantlf/jsonlint/commit/9f1f332960c91d9779bff995457154157df8823b))
|
|
206
|
+
|
|
207
|
+
## [8.0.2](https://github.com/prantlf/jsonlint/compare/v8.0.1...v8.0.2) (2019-07-04)
|
|
208
|
+
|
|
209
|
+
### Bug Fixes
|
|
210
|
+
|
|
211
|
+
* Put only the reason of the error to the error.reason property when the custom parser is used; not the full message including the error context ([8d7f0b1](https://github.com/prantlf/jsonlint/commit/8d7f0b13b2bfe7e854c965b7266e5de1dec79229))
|
|
212
|
+
* Update newline replacement regex to show correct error position on Windows ([7af364c](https://github.com/prantlf/jsonlint/commit/7af364cbafd84326f20f29adbacde1cd0f70e57a))
|
|
213
|
+
|
|
214
|
+
# [8.0.0](https://github.com/prantlf/jsonlint/compare/v7.0.3...v8.0.0) (2019-06-16)
|
|
215
|
+
|
|
216
|
+
### Bug Fixes
|
|
217
|
+
|
|
218
|
+
* Give the schema-drafts.js proper name and path in source maps ([c2f0148](https://github.com/prantlf/jsonlint/commit/c2f0148cb027e335fa2bb644f3c09a9c51303193))
|
|
219
|
+
|
|
220
|
+
### Features
|
|
221
|
+
|
|
222
|
+
* Add the tokenize method returning tokens instead of the parsed object ([cc7b554](https://github.com/prantlf/jsonlint/commit/cc7b55495b3287279aa0c27e242d3e90d8636d66))
|
|
223
|
+
* Improve schema error reporting to the level of data parsing ([ea5a8a2](https://github.com/prantlf/jsonlint/commit/ea5a8a2f917f6a07212f8a4e05af22c14e5f1883))
|
|
224
|
+
* Remove deprecated exports `Parser` and `parser` ([8bda5b1](https://github.com/prantlf/jsonlint/commit/8bda5b1455d8d176997dcce0bbcd622985888fc7))
|
|
225
|
+
|
|
226
|
+
### BREAKING CHANGES
|
|
227
|
+
|
|
228
|
+
* The `Parser` class and `parser` instance did not bring any benefit. They were generated by Jison. After abandoning the Jison parser they were kept for compatibility only. The only method on the `Parser` prototype was the `parse`. It remains unchanged as a direct export. Drop the class interface and just call the `parse` method directly.
|
|
229
|
+
|
|
230
|
+
## [7.0.3](https://github.com/prantlf/jsonlint/compare/v7.0.2...v7.0.3) (2019-06-03)
|
|
231
|
+
|
|
232
|
+
### Bug Fixes
|
|
233
|
+
|
|
234
|
+
* Ensure, that tokens and keys in error messages are enclosed in quotation marks ([2149198](https://github.com/prantlf/jsonlint/commit/2149198721fc8dd05632b2225c621ebf7b5e14b7))
|
|
235
|
+
|
|
236
|
+
## [7.0.2](https://github.com/prantlf/jsonlint/compare/v7.0.1...v7.0.2) (2019-06-02)
|
|
237
|
+
|
|
238
|
+
### Bug Fixes
|
|
239
|
+
|
|
240
|
+
* Upgrade minificating module ([04d80d7](https://github.com/prantlf/jsonlint/commit/04d80d752c4900f26585d9a809b8ac6d0eef696d))
|
|
241
|
+
|
|
242
|
+
## [7.0.1](https://github.com/prantlf/jsonlint/compare/v7.0.0...v7.0.1) (2019-06-02)
|
|
243
|
+
|
|
244
|
+
### Bug Fixes
|
|
245
|
+
|
|
246
|
+
* Recognize boxed string as schema environment too ([e37b004](https://github.com/prantlf/jsonlint/commit/e37b0042376cf5beafc93bf906ee70b583f08969))
|
|
247
|
+
|
|
248
|
+
# [7.0.0](https://github.com/prantlf/jsonlint/compare/v6.3.1...v7.0.0) (2019-06-02)
|
|
249
|
+
|
|
250
|
+
### Bug Fixes
|
|
251
|
+
|
|
252
|
+
* Do not use the native parser in Safari and Node.js 4 ([a4a606c](https://github.com/prantlf/jsonlint/commit/a4a606c333e443642ced99d466223607bce11461))
|
|
253
|
+
* Include the minified scripts used on the on-line page in the NPM module ([03561ec](https://github.com/prantlf/jsonlint/commit/03561ecba00c5d23dfba41831bea818837a7b804))
|
|
254
|
+
|
|
255
|
+
### Features
|
|
256
|
+
|
|
257
|
+
* Add "mode" parameter to set flags for a typical format type easier ([9aa09fb](https://github.com/prantlf/jsonlint/commit/9aa09fbc9980e78fa0fed134ce48d99412b619a9))
|
|
258
|
+
* Add an option for ignoring trailing commas in object and arrays ([7d521fb](https://github.com/prantlf/jsonlint/commit/7d521fb68ea7919625cc6bc5f5179ce69f6b5985))
|
|
259
|
+
* Add an option for reporting duplicate object keys as an error ([09e3977](https://github.com/prantlf/jsonlint/commit/09e39772de088b73e43dac551533a160bc09903c))
|
|
260
|
+
* Replace the parser generated by Jison with a hand-built parser from JJU ([2781670](https://github.com/prantlf/jsonlint/commit/27816706435fb48fb8816d743bc56d6d34c4c6c8))
|
|
261
|
+
* Support `reviver` from the native `JSON.parse` method ([83cd33c](https://github.com/prantlf/jsonlint/commit/83cd33c937851482799e01bf7262a9ba93bed6cf))
|
|
262
|
+
|
|
263
|
+
### BREAKING CHANGES
|
|
264
|
+
|
|
265
|
+
* There is no `yy.parseError` to intercept error handling. Use the thrown error - it contains all available information. The error does not include the `hash` object with structured information. Look for the [documentd properties](/prantlf/jsonlint#error-handling). The location of the error occurrence is available as `location.start`, for example.
|
|
266
|
+
|
|
267
|
+
DEPRECATION: The only exposed object to use from now on is the `parse` method as a named export. Other exports (`parser` and `Parser`) are deprecated and will be removed in future.
|
|
268
|
+
|
|
269
|
+
The parser from ["Utilities to work with JSON/JSON5 documents"](/rlidwka/jju) is four times faster, than the previous one, has approximatly the same size and can be easier enhanced, regarding both features and error handling.
|
|
270
|
+
|
|
271
|
+
## [6.3.1](https://github.com/prantlf/jsonlint/compare/v6.3.0...v6.3.1) (2019-05-31)
|
|
272
|
+
|
|
273
|
+
### Bug Fixes
|
|
274
|
+
|
|
275
|
+
* Recognise the location of error occurrences in Firefox ([7c8c040](https://github.com/prantlf/jsonlint/commit/7c8c040e8f9d259bf573c04f8f6a7df15587a54a))
|
|
276
|
+
|
|
277
|
+
# [6.3.0](https://github.com/prantlf/jsonlint/compare/v6.2.1...v6.3.0) (2019-05-30)
|
|
278
|
+
|
|
279
|
+
### Bug Fixes
|
|
280
|
+
|
|
281
|
+
* Auto-detect the version of the JSON Schema draft by default ([1fe98ef](https://github.com/prantlf/jsonlint/commit/1fe98ef4e3ee5cd26055e6f73f11387635a078a3))
|
|
282
|
+
* Prefer the native JSON parser, if possible, to improve performance ([1639356](https://github.com/prantlf/jsonlint/commit/16393562769a9f77741347fd9cda15c5207f1fee))
|
|
283
|
+
|
|
284
|
+
### Features
|
|
285
|
+
|
|
286
|
+
* Support parser options for customisation and performance in JSON schema parsing too ([d562826](https://github.com/prantlf/jsonlint/commit/d562826f604f8c3df5656a79ee4c2085c203f91c))
|
|
287
|
+
|
|
288
|
+
## [6.2.1](https://github.com/prantlf/jsonlint/compare/v6.2.0...v6.2.1) (2019-05-30)
|
|
289
|
+
|
|
290
|
+
### Bug Fixes
|
|
291
|
+
|
|
292
|
+
* Include source code in source maps on the on-line validator page ([31e0097](https://github.com/prantlf/jsonlint/commit/31e0097de3c2c5a30e3695d1d5b3f411dc7b6723))
|
|
293
|
+
|
|
294
|
+
# [6.2.0](https://github.com/prantlf/jsonlint/compare/v6.1.0...v6.2.0) (2019-05-30)
|
|
295
|
+
|
|
296
|
+
### Features
|
|
297
|
+
|
|
298
|
+
* Extract the functionality for sorting object keys to a module ([a53bd93](https://github.com/prantlf/jsonlint/commit/a53bd9392b2116b5272c77deee9423ba16b5f520))
|
|
299
|
+
|
|
300
|
+
# [6.1.0](https://github.com/prantlf/jsonlint/compare/v6.0.0...v6.1.0) (2019-05-27)
|
|
301
|
+
|
|
302
|
+
### Bug Fixes
|
|
303
|
+
|
|
304
|
+
* Fix the missing function object (Parser) in the main module exports ([eb892aa](https://github.com/prantlf/jsonlint/commit/eb892aab516754ec3bf2eb01ff575fe0c173a510))
|
|
305
|
+
* Restore context options (yy) set in the Parser constructor after the call to parse, if the options were overridden by the method arguments ([787c350](https://github.com/prantlf/jsonlint/commit/787c350c201ac0971e42d5b9f224689600e5c11f))
|
|
306
|
+
|
|
307
|
+
### Features
|
|
308
|
+
|
|
309
|
+
* Use the native JSON parser if a limited error information is enough ([8aa9fb1](https://github.com/prantlf/jsonlint/commit/8aa9fb10d6c6f7f148d8c7816cc73d6b8385aace))
|
|
310
|
+
|
|
311
|
+
# [6.0.0](https://github.com/prantlf/jsonlint/compare/v5.0.0...v6.0.0) (2019-05-26)
|
|
312
|
+
|
|
313
|
+
### Features
|
|
314
|
+
|
|
315
|
+
* Declare modules in this package using UMD ([d442583](https://github.com/prantlf/jsonlint/commit/d4425837cea5c11352f988e3723455b8d8f5115b))
|
|
316
|
+
* Remove ParserWithComments and parseWithComment from the interface ([3fab374](https://github.com/prantlf/jsonlint/commit/3fab374a0675a699dab3e8aed3bcf928b77fffe4))
|
|
317
|
+
|
|
318
|
+
### BREAKING CHANGES
|
|
319
|
+
|
|
320
|
+
* The object and the method do not exist any more. Pass the parameter "ignoreComments" as an object `{ ignoreComments: true }` either to the constructor of the `Parser` object, or as the second parameter to the method `parse`.
|
|
321
|
+
|
|
322
|
+
# [5.0.0](https://github.com/prantlf/jsonlint/compare/v4.0.2...v5.0.0) (2019-05-26)
|
|
323
|
+
|
|
324
|
+
### Bug Fixes
|
|
325
|
+
|
|
326
|
+
* Do not export "main" method, which requires other NPM modules ([d8af36a](https://github.com/prantlf/jsonlint/commit/d8af36ac292c68b0ee35460a5e7394a26fad4524))
|
|
327
|
+
|
|
328
|
+
### Features
|
|
329
|
+
|
|
330
|
+
* Accept single quotes (apostrophes) as string delimiters ([240b8cd](https://github.com/prantlf/jsonlint/commit/240b8cd916b7424e27f7ff585ca30512e87a6566))
|
|
331
|
+
|
|
332
|
+
### BREAKING CHANGES
|
|
333
|
+
|
|
334
|
+
* The "main" method providing a command-line interface importable from other module has been removed. If you used it, have a look at the command-line interface in `lib/cli`. You can import this module in instead and it offers a richer interface, than the previously exported "main" method. The `lib/cli` module is mapped to `bin/jsonlint` too. However, consider the default library export (`lib/jsonlint`) for programmatic usage. You will pack less JavaScript code and use smalker, mode programmer-oriented interface.
|
|
335
|
+
|
|
336
|
+
## [4.0.2](https://github.com/prantlf/jsonlint/compare/v4.0.1...v4.0.2) (2019-05-19)
|
|
337
|
+
|
|
338
|
+
### Bug Fixes
|
|
339
|
+
|
|
340
|
+
* Print parsing errors if the JSON input is read from stdin ([acfdf11](https://github.com/prantlf/jsonlint/commit/acfdf11e11a8f355cdd8fd1abf09edde664d8c02))
|
|
341
|
+
|
|
342
|
+
## [4.0.1](https://github.com/prantlf/jsonlint/compare/v4.0.0...v4.0.1) (2019-05-19)
|
|
343
|
+
|
|
344
|
+
### Bug Fixes
|
|
345
|
+
|
|
346
|
+
* Do not fail sorting objects with a property called "hasOwnProperty" ([b544ceb](https://github.com/prantlf/jsonlint/commit/b544ceb54d44e8273dd7a1d28fc7f69a527fd806))
|
|
347
|
+
|
|
348
|
+
# [4.0.0](https://github.com/prantlf/jsonlint/compare/v3.0.0...v4.0.0) (2019-05-19)
|
|
349
|
+
|
|
350
|
+
### Bug Fixes
|
|
351
|
+
|
|
352
|
+
* Standardize the interface of the "jsonlint/lib/formatter" module ([b8b041b](https://github.com/prantlf/jsonlint/commit/b8b041bcc0e6ea672ec4575c5b108f347cfef69a))
|
|
353
|
+
|
|
354
|
+
### Features
|
|
355
|
+
|
|
356
|
+
* Add web and programmatic interfaces to JSON Schema validation ([d45b243](https://github.com/prantlf/jsonlint/commit/d45b243bf1d083df58d9959d42eb3a787f5e7d89))
|
|
357
|
+
|
|
358
|
+
### BREAKING CHANGES
|
|
359
|
+
|
|
360
|
+
* The formatting method is exposed not as exports.formatter.formatJson, but as exports.format.
|
|
361
|
+
This module is not documented and it is unlikely, that it broke other project.
|
|
362
|
+
|
|
363
|
+
# [3.0.0](https://github.com/prantlf/jsonlint/compare/v2.0.1...v3.0.0) (2019-05-18)
|
|
364
|
+
|
|
365
|
+
### Bug Fixes
|
|
366
|
+
|
|
367
|
+
* Replace JSON schema validator JSV with ajv, because JSV is not maintained any more and does not support current JSON schema drafts ([1a4864f](https://github.com/prantlf/jsonlint/commit/1a4864f63ba14cb86a4e677fc23e5c1e963d2e07))
|
|
368
|
+
|
|
369
|
+
### BREAKING CHANGES
|
|
370
|
+
|
|
371
|
+
* The environment for the JSON schema validation "json-schema-draft-03" is not available any more.
|
|
372
|
+
Migrate your schemas from the JSON schema draft 03 to 04 or newer. Drafts 04, 06 and 07 are supported with this release.
|
|
373
|
+
|
|
374
|
+
## [2.0.1](https://github.com/prantlf/jsonlint/compare/v2.0.0...v2.0.1) (2019-05-18)
|
|
375
|
+
|
|
376
|
+
### Bug Fixes
|
|
377
|
+
|
|
378
|
+
* Do not depend on the standard checker in the release package ([1e9c7b5](https://github.com/prantlf/jsonlint/commit/1e9c7b5b5c091332270dbe6b2203fd66644bf355))
|
|
379
|
+
|
|
380
|
+
# [2.0.0](https://github.com/prantlf/jsonlint/compare/v1.7.0...v2.0.0) (2019-05-18)
|
|
381
|
+
|
|
382
|
+
### Bug Fixes
|
|
383
|
+
|
|
384
|
+
* Accept any file extension on the command line directly ([14ba31c](https://github.com/prantlf/jsonlint/commit/14ba31cf5adc0ddb24d6c318866b6bf9a3c6ae48))
|
|
385
|
+
* Do not distribute the web directory in the npm module ([7379be8](https://github.com/prantlf/jsonlint/commit/7379be83e3dc511785c4506e8ab55b77e014724e))
|
|
386
|
+
* Make the compact-errors mode working with the latest Jison output ([d417a9c](https://github.com/prantlf/jsonlint/commit/d417a9c39047be929b9f7589da9c2d3c188db7f9))
|
|
387
|
+
* Rename the long name of the option "extension" to "extensions" ([383e50a](https://github.com/prantlf/jsonlint/commit/383e50a6a00ee4641f8ae863b46e1af7bade7ee9))
|
|
388
|
+
* Replace nomnom as command-line parser with commander, which is maintaitained ([6694bba](https://github.com/prantlf/jsonlint/commit/6694bba56fc821cbe2622340c9753506fa026580))
|
|
389
|
+
* Report the right file name in the compact-errors mode, if multiple files or directories are engtered ([7c80326](https://github.com/prantlf/jsonlint/commit/7c80326a69a8df8f1f7ea66dced4a888ea321d9b))
|
|
390
|
+
|
|
391
|
+
### Features
|
|
392
|
+
|
|
393
|
+
* Add a checkbox to recognize JavaScript-style comments to the web page ([2a9082a](https://github.com/prantlf/jsonlint/commit/2a9082a26d1316a80ebf132d159e5bf49c3d0978))
|
|
394
|
+
* Support parsing and skipping JavaScript-style comments in the JSON input ([4955c58](https://github.com/prantlf/jsonlint/commit/4955c58788dd3b8c3a7a4358cbf65af72a353d0d))
|
|
395
|
+
|
|
396
|
+
### BREAKING CHANGES
|
|
397
|
+
|
|
398
|
+
* The options "extension" is not recognized any more.
|
|
399
|
+
Use the option "extensions" with the same semantics instead.
|
|
400
|
+
|
|
401
|
+
# [1.7.0](https://github.com/prantlf/jsonlint/compare/v1.6.4...v1.7.0) (2019-05-18)
|
|
402
|
+
|
|
403
|
+
### Features
|
|
404
|
+
|
|
405
|
+
* Allow specifying JSON file extensions for directory walk ([d8e8076](https://github.com/prantlf/jsonlint/commit/d8e8076edb831a577f5e272a5ea9e4edd077671b))
|
|
406
|
+
|
|
407
|
+
This is the first version released after forking the [original project](https://github.com/zaach/jsonlint).
|
package/README.md
CHANGED
|
@@ -135,7 +135,7 @@ Usage: `jsonlint [options] [<file, directory, pattern> ...]`
|
|
|
135
135
|
-S, --single-quoted-strings support single quotes as string delimiters
|
|
136
136
|
-T, --trailing-commas ignore trailing commas in objects and arrays
|
|
137
137
|
-D, --no-duplicate-keys report duplicate object keys as an error
|
|
138
|
-
-V, --validate [file] JSON
|
|
138
|
+
-V, --validate [file] JSON Schema file to use for validation
|
|
139
139
|
-e, --environment [env] which specification of JSON Schema the
|
|
140
140
|
validation file uses
|
|
141
141
|
-x, --context [num] line count used as the diff context (default: 3)
|
|
@@ -164,8 +164,10 @@ A pattern to exclude from processing starts with "!".
|
|
|
164
164
|
|
|
165
165
|
Parsing mode can be "cjson" or "json5" to enable other flags automatically.
|
|
166
166
|
If no files or directories are specified, stdin will be parsed. Environments
|
|
167
|
-
for JSON
|
|
168
|
-
or "
|
|
167
|
+
for JSON Schema validation are "draft-04", "draft-06", "draft-07",
|
|
168
|
+
"draft-2019-09" or "draft-2020-12". The environment may be prefixed
|
|
169
|
+
with "json-schema-". JSON Type Definition can be selected by "rfc8927",
|
|
170
|
+
"json-type-definition" or "jtd". If not specified, it will be "draft-07".
|
|
169
171
|
|
|
170
172
|
### Configuration
|
|
171
173
|
|
|
@@ -272,21 +274,19 @@ The `mode` parameter (string) sets parsing options to match a common format of i
|
|
|
272
274
|
|
|
273
275
|
### Schema Validation
|
|
274
276
|
|
|
275
|
-
You can validate the input against a JSON
|
|
277
|
+
You can validate the input against a JSON Schema using the `lib/validator` module. The `validate` method accepts either an earlier parsed JSON data or a string with the JSON input:
|
|
276
278
|
|
|
277
279
|
```js
|
|
278
280
|
const { compile } = require('@prantlf/jsonlint/lib/validator')
|
|
279
|
-
const validate = compile('string with JSON
|
|
281
|
+
const validate = compile('string with JSON Schema')
|
|
280
282
|
// Throws an error in case of failure.
|
|
281
283
|
const parsed = validate('string with JSON data')
|
|
282
284
|
```
|
|
283
285
|
|
|
284
|
-
If a string is passed to the `validate` method, the same options as for parsing JSON data can be passed as the second parameter. Compiling JSON
|
|
286
|
+
If a string is passed to the `validate` method, the same options as for parsing JSON data can be passed as the second parameter. Compiling JSON Schema supports the same options as parsing JSON data too (except for `reviver`). They can be passed as the second (object) parameter. The optional second `environment` parameter can be passed either as a string or as an additional property in the options object too:
|
|
285
287
|
|
|
286
288
|
```js
|
|
287
|
-
const validate = compile('string with JSON
|
|
288
|
-
environment: 'json-schema-draft-04'
|
|
289
|
-
})
|
|
289
|
+
const validate = compile('string with JSON Schema', { environment: 'draft-2020-12' })
|
|
290
290
|
```
|
|
291
291
|
|
|
292
292
|
### Pretty-Printing
|
package/lib/cli.js
CHANGED
|
@@ -31,7 +31,7 @@ const commander = require('commander')
|
|
|
31
31
|
.option('-S, --single-quoted-strings', 'support single quotes as string delimiters')
|
|
32
32
|
.option('-T, --trailing-commas', 'ignore trailing commas in objects and arrays')
|
|
33
33
|
.option('-D, --no-duplicate-keys', 'report duplicate object keys as an error')
|
|
34
|
-
.option('-V, --validate [file]', 'JSON
|
|
34
|
+
.option('-V, --validate [file]', 'JSON Schema file to use for validation')
|
|
35
35
|
.option('-e, --environment [env]', 'which specification of JSON Schema the validation file uses')
|
|
36
36
|
.option('-x, --context [num]', 'line count used as the diff context', 3)
|
|
37
37
|
.option('-l, --log-files', 'print only the parsed file names to stdout')
|
|
@@ -55,8 +55,10 @@ const commander = require('commander')
|
|
|
55
55
|
console.log()
|
|
56
56
|
console.log('Parsing mode can be "cjson" or "json5" to enable other flags automatically.')
|
|
57
57
|
console.log('If no files or directories are specified, stdin will be parsed. Environments')
|
|
58
|
-
console.log('for JSON
|
|
59
|
-
console.log('or "
|
|
58
|
+
console.log('for JSON Schema validation are "draft-04", "draft-06", "draft-07",')
|
|
59
|
+
console.log('"draft-2019-09" or "draft-2020-12". The environment may be prefixed')
|
|
60
|
+
console.log('with "json-schema-". JSON Type Definition can be selected by "rfc8927",')
|
|
61
|
+
console.log('"json-type-definition" or "jtd". If not specified, it will be "draft-07".')
|
|
60
62
|
})
|
|
61
63
|
.parse(process.argv)
|
|
62
64
|
|
|
@@ -149,7 +151,7 @@ function processContents (source, file) {
|
|
|
149
151
|
parserOptions.environment = options.environment
|
|
150
152
|
validate = compile(schema, parserOptions)
|
|
151
153
|
} catch (error) {
|
|
152
|
-
const message = 'Loading the JSON
|
|
154
|
+
const message = 'Loading the JSON Schema failed: "' +
|
|
153
155
|
options.validate + '".\n' + error.message
|
|
154
156
|
throw new Error(message)
|
|
155
157
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -362,7 +362,11 @@ declare module '@prantlf/jsonlint/lib/validator' {
|
|
|
362
362
|
/**
|
|
363
363
|
* Identifiers of supported JSON Schema drafts and JSON Type Definition.
|
|
364
364
|
*/
|
|
365
|
-
type Environment = 'json-schema-draft-04' | '
|
|
365
|
+
type Environment = 'json-schema-draft-04' | 'draft-04' |
|
|
366
|
+
'json-schema-draft-06' | 'draft-06' | 'json-schema-draft-07' | 'draft-07' |
|
|
367
|
+
'json-schema-draft-2019-09' | 'draft-2019-09' |
|
|
368
|
+
'json-schema-draft-2020-12' | 'draft-2020-12' |
|
|
369
|
+
'json-type-definition' | 'jtd' | 'rfc8927'
|
|
366
370
|
|
|
367
371
|
/**
|
|
368
372
|
* Options to customize a JSON Schema validator.
|
|
@@ -414,7 +418,11 @@ declare module '@prantlf/jsonlint/lib/validator' {
|
|
|
414
418
|
/**
|
|
415
419
|
* Choose the JSON Schema draft or JSON Type Definition.
|
|
416
420
|
*
|
|
417
|
-
* Available values: `'json-schema-draft-04' | '
|
|
421
|
+
* Available values: `'json-schema-draft-04' | 'draft-04' |
|
|
422
|
+
* 'json-schema-draft-06' | 'draft-06' | 'json-schema-draft-07' | 'draft-07' |
|
|
423
|
+
* 'json-schema-draft-2019-09' | 'draft-2019-09' |
|
|
424
|
+
* 'json-schema-draft-2020-12' | 'draft-2020-12' |
|
|
425
|
+
* 'json-type-definition' | 'jtd' | 'rfc8927'`
|
|
418
426
|
*/
|
|
419
427
|
environment?: Environment
|
|
420
428
|
}
|
package/lib/validator.js
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
|
3
3
|
const jsonlint = require('./jsonlint')
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const ajv = {
|
|
5
|
+
Ajv04: 'ajv-draft-04',
|
|
6
|
+
Ajv07: 'ajv',
|
|
7
|
+
AjvJTD: 'ajv/dist/jtd',
|
|
8
|
+
Ajv2019: 'ajv/dist/2019',
|
|
9
|
+
Ajv2020: 'ajv/dist/2020',
|
|
10
|
+
Schema06: 'ajv/dist/refs/json-schema-draft-06.json'
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
const requireAjv = name => {
|
|
13
|
+
const exported = require(ajv[name])
|
|
14
|
+
return !exported.$schema && exported.default || exported
|
|
15
|
+
}
|
|
16
|
+
factory(exports, jsonlint, requireAjv)
|
|
11
17
|
} else if (typeof define === 'function' && define.amd) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
18
|
+
define('jsonlint-validator', ['exports', 'jsonlint', 'ajv'],
|
|
19
|
+
function (exports, jsonlint, ajv) {
|
|
20
|
+
const requireAjv = name => {
|
|
21
|
+
const exported = ajv[name]
|
|
22
|
+
return !exported.$schema && exported.default || exported
|
|
17
23
|
}
|
|
18
|
-
factory(exports,
|
|
24
|
+
factory(exports, jsonlint, requireAjv)
|
|
19
25
|
})
|
|
20
26
|
} else {
|
|
21
|
-
// eslint-disable-next-line no-undef
|
|
22
27
|
global = global || self
|
|
23
|
-
const
|
|
24
|
-
|
|
28
|
+
const requireAjv = name => {
|
|
29
|
+
const exported = global.ajv[name]
|
|
30
|
+
return !exported.$schema && exported.default || exported
|
|
25
31
|
}
|
|
26
|
-
factory(global.jsonlintValidator = {}, global.
|
|
32
|
+
factory(global.jsonlintValidator = {}, global.jsonlint, requireAjv)
|
|
27
33
|
}
|
|
28
|
-
}(this, function (exports,
|
|
34
|
+
}(this, function (exports, jsonlint, requireAjv) {
|
|
29
35
|
'use strict'
|
|
30
36
|
|
|
31
37
|
function addErrorLocation (problem, input, tokens, dataPath) {
|
|
@@ -96,24 +102,28 @@
|
|
|
96
102
|
}
|
|
97
103
|
|
|
98
104
|
function createAjv (environment) {
|
|
99
|
-
const ajvOptions = { jsonPointers: true }
|
|
100
105
|
let ajv
|
|
101
|
-
if (!environment) {
|
|
102
|
-
|
|
103
|
-
ajv = new Ajv(
|
|
104
|
-
ajv.addMetaSchema(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
ajv = new Ajv(
|
|
108
|
-
} else if (environment === 'json-schema-draft-
|
|
109
|
-
|
|
110
|
-
ajv
|
|
111
|
-
} else if (environment === 'json-schema-draft-
|
|
112
|
-
|
|
113
|
-
ajv = new Ajv(
|
|
114
|
-
|
|
106
|
+
if (!environment || environment === 'json-schema-draft-06' || environment === 'draft-06') {
|
|
107
|
+
const Ajv = requireAjv('Ajv07')
|
|
108
|
+
ajv = new Ajv()
|
|
109
|
+
ajv.addMetaSchema(requireAjv('Schema06'))
|
|
110
|
+
} else if (environment === 'json-schema-draft-07' || environment === 'draft-07') {
|
|
111
|
+
const Ajv = requireAjv('Ajv07')
|
|
112
|
+
ajv = new Ajv()
|
|
113
|
+
} else if (environment === 'json-schema-draft-04' || environment === 'draft-04') {
|
|
114
|
+
const Ajv = requireAjv('Ajv04')
|
|
115
|
+
ajv = new Ajv()
|
|
116
|
+
} else if (environment === 'json-schema-draft-2019-09' || environment === 'draft-2019-09') {
|
|
117
|
+
const Ajv = requireAjv('Ajv2019')
|
|
118
|
+
ajv = new Ajv()
|
|
119
|
+
} else if (environment === 'json-schema-draft-2020-12' || environment === 'draft-2020-12') {
|
|
120
|
+
const Ajv = requireAjv('Ajv2020')
|
|
121
|
+
ajv = new Ajv()
|
|
122
|
+
} else if (environment === 'json-type-definition' || environment === 'jtd' || environment === 'rfc8927') {
|
|
123
|
+
const Ajv = requireAjv('AjvJTD')
|
|
124
|
+
ajv = new Ajv()
|
|
115
125
|
} else {
|
|
116
|
-
throw new RangeError('Unsupported environment for the JSON
|
|
126
|
+
throw new RangeError('Unsupported environment for the JSON Schema validation: "' +
|
|
117
127
|
environment + '".')
|
|
118
128
|
}
|
|
119
129
|
return ajv
|
|
@@ -124,7 +134,7 @@
|
|
|
124
134
|
try {
|
|
125
135
|
parsed = jsonlint.parse(schema, parseOptions)
|
|
126
136
|
} catch (error) {
|
|
127
|
-
error.message = 'Parsing the JSON
|
|
137
|
+
error.message = 'Parsing the JSON Schema failed.\n' + error.message
|
|
128
138
|
throw error
|
|
129
139
|
}
|
|
130
140
|
try {
|
|
@@ -134,7 +144,7 @@
|
|
|
134
144
|
const betterError = errors
|
|
135
145
|
? createError(errors, parsed, schema, parseOptions)
|
|
136
146
|
: originalError
|
|
137
|
-
betterError.message = 'Compiling the JSON
|
|
147
|
+
betterError.message = 'Compiling the JSON Schema failed.\n' + betterError.message
|
|
138
148
|
throw betterError
|
|
139
149
|
}
|
|
140
150
|
}
|