@prantlf/jsonlint 11.1.0 → 11.3.0

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/README.md CHANGED
@@ -17,10 +17,11 @@ This is a fork of the original project ([zaach/jsonlint](https://github.com/zaac
17
17
  * Supports [JSON Schema] drafts 04, 06 and 07.
18
18
  * Offers pretty-printing including comment-stripping and object keys without quotes (JSON5).
19
19
  * Prefers the native JSON parser if possible to run [7x faster than the custom parser].
20
- * Reports errors with rich additional information. From the schema validation too.
21
- * Implements JavaScript modules using [UMD] to work everywhere.
20
+ * Reports errors with rich additional information. From the JSON Schema validation too.
21
+ * Consumes configuration from both command line and [configuration files](configuration).
22
+ * Implements JavaScript modules using [UMD] to work in Node.js, in a browser, everywhere.
22
23
  * Depends on up-to-date npm modules with no installation warnings.
23
- * Small size - 18.2 kB minified, 6.3 kB gzipped.
24
+ * Small size - 18.7 kB minified, 6.54 kB gzipped, 5.16 kB brotlied.
24
25
 
25
26
  **Note:** In comparison with the original project, this package exports only the `parse` method; not the `Parser` object.
26
27
 
@@ -52,9 +53,11 @@ Example of an error message:
52
53
 
53
54
  ## Command-line Interface
54
55
 
55
- Install `jsonlint` with `npm`` globally to be able to use the command-line interface in any directory:
56
+ Install `jsonlint` with `npm`, `pnpm` or `yarn` globally to be able to use the command-line interface in any directory:
56
57
 
57
- npm i @prantlf/jsonlint -g
58
+ npm i -g @prantlf/jsonlint
59
+ pnpm i -g @prantlf/jsonlint
60
+ yarn add --global @prantlf/jsonlint
58
61
 
59
62
  Validate a single file:
60
63
 
@@ -64,57 +67,129 @@ or pipe the JSON input into `stdin`:
64
67
 
65
68
  cat myfile.json | jsonlint
66
69
 
67
- or process all `.json` files in a directory:
70
+ or process all `.json` files in a directory and rewriting them with the pretty-printed output:
68
71
 
69
- jsonlint mydir
72
+ jsonlint --in-place --pretty-print mydir
70
73
 
71
74
  By default, `jsonlint` will either report a syntax error with details or pretty-print the source if it is valid.
72
75
 
73
- ### Options
74
-
75
- $ jsonlint -h
76
-
77
- Usage: jsonlint [options] [<file or directory> ...]
78
-
79
- JSON parser, syntax and schema validator and pretty-printer.
80
-
81
- Options:
82
- -s, --sort-keys sort object keys (not when prettifying)
83
- -E, --extensions [ext] file extensions to process for directory walk
84
- (default: ["json","JSON"])
85
- -i, --in-place overwrite the input files
86
- -t, --indent [num|char] number of spaces or specific characters
87
- to use for indentation (default: 2)
88
- -c, --compact compact error display
89
- -M, --mode [mode] set other parsing flags according to a format
90
- type (default: "json")
91
- -C, --comments recognize and ignore JavaScript-style comments
92
- -S, --single-quoted-strings support single quotes as string delimiters
93
- -T, --trailing-commas ignore trailing commas in objects and arrays
94
- -D, --no-duplicate-keys report duplicate object keys as an error
95
- -V, --validate [file] JSON schema file to use for validation
96
- -e, --environment [env] which specification of JSON Schema the
97
- validation file uses
98
- -q, --quiet do not print the parsed json to stdin
99
- -p, --pretty-print prettify the input instead of stringifying
100
- the parsed object
101
- -P, --pretty-print-invalid force pretty-printing even for invalid input
102
- -r, --trailing-newline ensure a line break at the end of the output
103
- --prune-comments omit comments from the prettified output
104
- --strip-object-keys strip quotes from object keys if possible
105
- (JSON5)
106
- --enforce-double-quotes surrounds all strings with double quotes
107
- --enforce-single-quotes surrounds all strings with single quotes
108
- (JSON5)
109
- --trim-trailing-commas omit trailing commas from objects and arrays
110
- (JSON5)
111
- -v, --version output the version number
112
- -h, --help output usage information
113
-
114
- Parsing mode can be "cjson" or "json5" to enable other flags automatically.
115
- If no files or directories are specified, stdin will be parsed. Environments
116
- for JSON schema validation are "json-schema-draft-04", "json-schema-draft-06"
117
- or "json-schema-draft-07". If not specified, it will be auto-detected.
76
+ A more complex example: check all JSON files in a Node.js project, except for dependencies in `node_modules`, allow comments (CJSON) and trailing commas, forbid duplicated object keys, print processed files names on the console, print errors on a single line and if an error occurs, continue with other files:
77
+
78
+ jsonlint --comments --trailing-commas --no-duplicate-keys \
79
+ --log-files --compact --continue '**/*.json' '!**/node_modules'
80
+
81
+ The same parameters can be passed from a configuration file:
82
+
83
+ ```json
84
+ {
85
+ "comments": true,
86
+ "trailing-commas": true,
87
+ "duplicate-keys": false,
88
+ "log-files": true,
89
+ "compact": true,
90
+ "continue": true,
91
+ "patterns": ["**/*.json", "!**/node_modules"]
92
+ }
93
+ ```
94
+
95
+ ### Usage
96
+
97
+ Usage: `jsonlint [options] [<file, directory, pattern> ...]`
98
+
99
+ #### Options
100
+
101
+ -f, --config [file] read options from a custom configuration file
102
+ -F, --no-config disable searching for configuration file
103
+ -s, --sort-keys sort object keys (not when prettifying)
104
+ -E, --extensions [ext] file extensions to process for directory walk
105
+ (default: ["json","JSON"])
106
+ -i, --in-place overwrite the input files
107
+ -t, --indent [num|char] number of spaces or specific characters
108
+ to use for indentation (default: 2)
109
+ -c, --compact compact error display
110
+ -M, --mode [mode] set other parsing flags according to a format
111
+ type (default: "json")
112
+ -C, --comments recognize and ignore JavaScript-style comments
113
+ -S, --single-quoted-strings support single quotes as string delimiters
114
+ -T, --trailing-commas ignore trailing commas in objects and arrays
115
+ -D, --no-duplicate-keys report duplicate object keys as an error
116
+ -V, --validate [file] JSON schema file to use for validation
117
+ -e, --environment [env] which specification of JSON Schema the
118
+ validation file uses
119
+ -l, --log-files print only the parsed file names to stdout
120
+ -q, --quiet do not print the parsed json to stdout
121
+ -n, --continue continue with other files if an error occurs
122
+ -p, --pretty-print prettify the input instead of stringifying
123
+ the parsed object
124
+ -P, --pretty-print-invalid force pretty-printing even for invalid input
125
+ -r, --trailing-newline ensure a line break at the end of the output
126
+ -R, --no-trailing-newline ensure no line break at the end of the output
127
+ --prune-comments omit comments from the prettified output
128
+ --strip-object-keys strip quotes from object keys if possible
129
+ (JSON5)
130
+ --enforce-double-quotes surrounds all strings with double quotes
131
+ --enforce-single-quotes surrounds all strings with single quotes
132
+ (JSON5)
133
+ --trim-trailing-commas omit trailing commas from objects and arrays
134
+ (JSON5)
135
+ -v, --version output the version number
136
+ -h, --help output usage information
137
+
138
+ You can use BASH patterns for including and excluding files (only files).
139
+ Patterns are case-sensitive and have to use slashes as a path separators.
140
+ A pattern to exclude from processing starts with "!".
141
+
142
+ Parsing mode can be "cjson" or "json5" to enable other flags automatically.
143
+ If no files or directories are specified, stdin will be parsed. Environments
144
+ for JSON schema validation are "json-schema-draft-04", "json-schema-draft-06"
145
+ or "json-schema-draft-07". If not specified, it will be auto-detected.
146
+
147
+ ### Configuration
148
+
149
+ In addition to the command line parameters, the options can be supplied from the following files:
150
+
151
+ package.json, key jsonlint
152
+ .jsonlintrc
153
+ .jsonlintrc.json
154
+ .jsonlintrc.yaml
155
+ .jsonlintrc.yml
156
+ .jsonlintrc.js
157
+ .jsonlintrc.cjs
158
+ jsonlint.config.js
159
+ jsonlint.config.cjs
160
+
161
+ The automatic search for one of the following locations above can be disabled by the command-line parameter `-F|--no-config`. A concrete configuration file can be specified by the command-line parameter `-f|--config [file]`. Parameters from the command line will have higher priority than parameters from a configuration file.
162
+
163
+ The configuration is an object with the following properties, described above, which can be entered either in the kebab-case or in the camel-case:
164
+
165
+ | Parameter | Alias |
166
+ | --------- | ----- |
167
+ | patterns | |
168
+ | sort-keys | sortKeys |
169
+ | extensions | |
170
+ | in-place | inPlace |
171
+ | indent | |
172
+ | compact | |
173
+ | mode | |
174
+ | comments | |
175
+ | single-quoted-strings | singleQuotedStrings |
176
+ | trailing-commas | trailingCommas |
177
+ | duplicate-keys | duplicateKeys |
178
+ | validate | |
179
+ | environment | |
180
+ | log-files | logFiles |
181
+ | quiet | |
182
+ | continue | |
183
+ | pretty-print | prettyPrint |
184
+ | pretty-print-invalid | prettyPrintInvalid |
185
+ | trailing-newline | trailingNewline'
186
+ | prune-comments | pruneComments |
187
+ | strip-object-keys | stripObjectKeys |
188
+ | enforce-double-quotes | enforceDoubleQuotes |
189
+ | enforce-single-quotes | enforceSingleQuotes |
190
+ | trim-trailing-commas | trimTrailingCommas |
191
+
192
+ The parameter `config` will be ignored in configuration files. The extra parameter `patterns` can be set to an array of strings with paths or patterns instead of putting them to the command line.
118
193
 
119
194
  ## Module Interface
120
195
 
@@ -324,7 +399,6 @@ Licensed under the [MIT License].
324
399
 
325
400
  [MIT License]: http://en.wikipedia.org/wiki/MIT_License
326
401
  [pure JavaScript version]: http://prantlf.github.com/jsonlint/
327
- [jsonlint.com]: http://jsonlint.com
328
402
  [JSON]: https://tools.ietf.org/html/rfc8259
329
403
  [JSON5]: https://spec.json5.org
330
404
  [JSON Schema]: https://json-schema.org
package/lib/cli.js CHANGED
@@ -1,24 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const fs = require('fs')
4
- const path = require('path')
5
- const parser = require('./jsonlint')
6
- const formatter = require('./formatter')
7
- const printer = require('./printer')
8
- const sorter = require('./sorter')
9
- const validator = require('./validator')
10
- const pkg = require('../package')
11
-
12
- function collectExtensions (extension) {
13
- return extension.split(',')
14
- }
3
+ const { readdirSync, readFileSync, statSync, writeFileSync } = require('fs')
4
+ const { extname, join, normalize } = require('path')
5
+ const { isDynamicPattern, sync } = require('fast-glob')
6
+ const { cosmiconfigSync } = require('cosmiconfig')
7
+ const { parse, tokenize } = require('./jsonlint')
8
+ const { format } = require('./formatter')
9
+ const { print } = require('./printer')
10
+ const { sortObject } = require('./sorter')
11
+ const { compile } = require('./validator')
12
+ const { description, version } = require('../package')
13
+
14
+ const collectValues = extension => extension.split(',')
15
15
 
16
16
  const commander = require('commander')
17
17
  .name('jsonlint')
18
- .usage('[options] [<file or directory> ...]')
19
- .description(pkg.description)
18
+ .usage('[options] [<file, directory, pattern> ...]')
19
+ .description(description)
20
+ .option('-f, --config [file]', 'read options from a custom configuration file')
21
+ .option('-F, --no-config', 'disable searching for configuration files')
20
22
  .option('-s, --sort-keys', 'sort object keys (not when prettifying)')
21
- .option('-E, --extensions [ext]', 'file extensions to process for directory walk', collectExtensions, ['json', 'JSON'])
23
+ .option('-E, --extensions [ext]', 'file extensions to process for directory walk', collectValues, ['json', 'JSON'])
22
24
  .option('-i, --in-place', 'overwrite the input files')
23
25
  .option('-t, --indent [num|char]', 'number of spaces or specific characters to use for indentation', 2)
24
26
  .option('-c, --compact', 'compact error display')
@@ -29,17 +31,24 @@ const commander = require('commander')
29
31
  .option('-D, --no-duplicate-keys', 'report duplicate object keys as an error')
30
32
  .option('-V, --validate [file]', 'JSON schema file to use for validation')
31
33
  .option('-e, --environment [env]', 'which specification of JSON Schema the validation file uses')
32
- .option('-q, --quiet', 'do not print the parsed json to stdin')
34
+ .option('-l, --log-files', 'print only the parsed file names to stdout')
35
+ .option('-q, --quiet', 'do not print the parsed json to stdout')
36
+ .option('-n, --continue', 'continue with other files if an error occurs')
33
37
  .option('-p, --pretty-print', 'prettify the input instead of stringifying the parsed object')
34
38
  .option('-P, --pretty-print-invalid', 'force pretty-printing even for invalid input')
35
39
  .option('-r, --trailing-newline', 'ensure a line break at the end of the output')
40
+ .option('-R, --no-trailing-newline', 'ensure no line break at the end of the output')
36
41
  .option('--prune-comments', 'omit comments from the prettified output')
37
42
  .option('--strip-object-keys', 'strip quotes from object keys if possible (JSON5)')
38
43
  .option('--enforce-double-quotes', 'surrounds all strings with double quotes')
39
44
  .option('--enforce-single-quotes', 'surrounds all strings with single quotes (JSON5)')
40
45
  .option('--trim-trailing-commas', 'omit trailing commas from objects and arrays (JSON5)')
41
- .version(pkg.version, '-v, --version')
46
+ .version(version, '-v, --version')
42
47
  .on('--help', () => {
48
+ console.log()
49
+ console.log('You can use BASH patterns for including and excluding files (only files).')
50
+ console.log('Patterns are case-sensitive and have to use slashes as a path separators.')
51
+ console.log('A pattern to exclude from processing starts with "!".')
43
52
  console.log()
44
53
  console.log('Parsing mode can be "cjson" or "json5" to enable other flags automatically.')
45
54
  console.log('If no files or directories are specified, stdin will be parsed. Environments')
@@ -48,9 +57,60 @@ const commander = require('commander')
48
57
  })
49
58
  .parse(process.argv)
50
59
 
51
- const options = commander.opts()
60
+ const paramNames = {
61
+ 'trailing-commas': 'trailingCommas',
62
+ 'single-quoted-strings': 'singleQuotedStrings',
63
+ 'duplicate-keys': 'duplicateKeys',
64
+ 'pretty-print': 'prettyPrint',
65
+ 'prune-comments': 'pruneComments',
66
+ 'strip-object-keys': 'stripObjectKeys',
67
+ 'enforce-double-quotes': 'enforceDoubleQuotes',
68
+ 'enforce-single-quotes': 'enforceSingleQuotes',
69
+ 'trim-trailing-commas': 'trimTrailingCommas',
70
+ 'sort-keys': 'sortKeys',
71
+ 'pretty-print-invalid': 'prettyPrintInvalid',
72
+ 'log-files': 'logFiles',
73
+ 'in-place': 'inPlace',
74
+ 'trailing-newline': 'trailingNewline'
75
+ }
76
+
77
+ const params = commander.opts()
78
+ let options
79
+ if (params.config === false) {
80
+ options = params
81
+ } else {
82
+ const configurator = cosmiconfigSync('jsonlint')
83
+ const { config = {} } = (params.config && configurator.load(params.config)) ||
84
+ configurator.search() || {}
85
+ options = mergeOptions({}, convertConfig(config), params)
86
+ }
87
+
88
+ const extensions = options.extensions.map(extension => '.' + extension)
89
+
90
+ function convertConfig (config) {
91
+ const result = {}
92
+ for (const key in config) {
93
+ const name = paramNames[key] || key
94
+ result[name] = config[key]
95
+ }
96
+ return result
97
+ }
98
+
99
+ function mergeOptions (target, ...sources) {
100
+ for (const source of sources) {
101
+ for (const key in source) {
102
+ if (target[key] == null) {
103
+ target[key] = source[key]
104
+ }
105
+ }
106
+ }
107
+ return target
108
+ }
52
109
 
53
110
  function logNormalError (error, file) {
111
+ if (process.exitCode > 0) {
112
+ console.log()
113
+ }
54
114
  console.log('File:', file)
55
115
  console.error(error.message)
56
116
  }
@@ -60,7 +120,7 @@ function logCompactError (error, file) {
60
120
  ', col ' + error.location.start.column + ', ' + error.reason + '.')
61
121
  }
62
122
 
63
- function parse (source, file) {
123
+ function processContents (source, file) {
64
124
  let parserOptions, parsed, formatted
65
125
  try {
66
126
  parserOptions = {
@@ -73,9 +133,9 @@ function parse (source, file) {
73
133
  if (options.validate) {
74
134
  let validate
75
135
  try {
76
- const schema = fs.readFileSync(path.normalize(options.validate), 'utf8')
136
+ const schema = readFileSync(normalize(options.validate), 'utf8')
77
137
  parserOptions.environment = options.environment
78
- validate = validator.compile(schema, parserOptions)
138
+ validate = compile(schema, parserOptions)
79
139
  } catch (error) {
80
140
  const message = 'Loading the JSON schema failed: "' +
81
141
  options.validate + '".\n' + error.message
@@ -83,13 +143,13 @@ function parse (source, file) {
83
143
  }
84
144
  parsed = validate(source, parserOptions)
85
145
  } else {
86
- parsed = parser.parse(source, parserOptions)
146
+ parsed = parse(source, parserOptions)
87
147
  }
88
148
  if (options.prettyPrint) {
89
149
  parserOptions.rawTokens = true
90
- const tokens = parser.tokenize(source, parserOptions)
150
+ const tokens = tokenize(source, parserOptions)
91
151
  // TODO: Support sorting tor the tokenized input too.
92
- return printer.print(tokens, {
152
+ return print(tokens, {
93
153
  indent: options.indent,
94
154
  pruneComments: options.pruneComments,
95
155
  stripObjectKeys: options.stripObjectKeys,
@@ -99,7 +159,7 @@ function parse (source, file) {
99
159
  })
100
160
  }
101
161
  if (options.sortKeys) {
102
- parsed = sorter.sortObject(parsed)
162
+ parsed = sortObject(parsed)
103
163
  }
104
164
  return JSON.stringify(parsed, null, options.indent)
105
165
  } catch (e) {
@@ -110,9 +170,9 @@ function parse (source, file) {
110
170
  * manual formatter because the automatic one is faster and probably more reliable.
111
171
  */
112
172
  try {
113
- formatted = formatter.format(source, options.indent)
173
+ formatted = format(source, options.indent)
114
174
  // Re-parse so exception output gets better line numbers
115
- parsed = parser.parse(formatted)
175
+ parsed = parse(formatted)
116
176
  } catch (e) {
117
177
  if (options.compact) {
118
178
  logCompactError(e, file)
@@ -129,67 +189,100 @@ function parse (source, file) {
129
189
  logNormalError(e, file)
130
190
  }
131
191
  }
132
- process.exit(1)
192
+ if (options.continue) {
193
+ process.exitCode = 1
194
+ } else {
195
+ process.exit(1)
196
+ }
133
197
  }
134
198
  }
135
199
 
136
200
  function processFile (file) {
137
- file = path.normalize(file)
138
- let source = parse(fs.readFileSync(file, 'utf8'), file)
201
+ file = normalize(file)
202
+ if (options.logFiles) {
203
+ console.log(file)
204
+ }
205
+ const original = readFileSync(file, 'utf8')
206
+ let source = processContents(original, file)
139
207
  if (options.inPlace) {
140
- if (options.trailingNewline) {
208
+ const lines = original.split(/\r?\n/)
209
+ const newLine = !lines[lines.length - 1]
210
+ if (options.trailingNewline === true ||
211
+ (options.trailingNewline !== false && newLine)) {
141
212
  source += '\n'
142
213
  }
143
- fs.writeFileSync(file, source)
214
+ writeFileSync(file, source)
144
215
  } else {
145
- if (!options.quiet) {
216
+ if (!(options.quiet || options.logFiles)) {
146
217
  console.log(source)
147
218
  }
148
219
  }
149
220
  }
150
221
 
151
- function processSources (src, checkExtension) {
152
- const extensions = options.extensions.map(function (extension) {
153
- return '.' + extension
154
- })
155
- let srcStat
222
+ function processSource (src, checkExtension) {
156
223
  try {
157
- srcStat = fs.statSync(src)
224
+ const srcStat = statSync(src)
158
225
  if (srcStat.isFile()) {
159
226
  if (checkExtension) {
160
- const ext = path.extname(src)
227
+ const ext = extname(src)
161
228
  if (extensions.indexOf(ext) < 0) {
162
229
  return
163
230
  }
164
231
  }
165
232
  processFile(src)
166
233
  } else if (srcStat.isDirectory()) {
167
- const sources = fs.readdirSync(src)
168
- for (let i = 0; i < sources.length; i++) {
169
- processSources(path.join(src, sources[i]), true)
234
+ const sources = readdirSync(src)
235
+ for (const source of sources) {
236
+ processSource(join(src, source), true)
170
237
  }
171
238
  }
172
- } catch (err) {
173
- console.log('WARN', err.message)
239
+ } catch ({ message }) {
240
+ console.log('WARN', message)
241
+ }
242
+ }
243
+
244
+ function processPatterns (patterns) {
245
+ const files = sync(patterns, { onlyFiles: true })
246
+ if (!files.length) {
247
+ console.log('no files found')
248
+ process.exit(1)
249
+ }
250
+ for (const file of files) {
251
+ try {
252
+ processFile(file)
253
+ } catch ({ message }) {
254
+ console.log('WARN', message)
255
+ }
174
256
  }
175
257
  }
176
258
 
177
259
  function main () {
178
- const files = commander.args
179
- let source = ''
260
+ let { args: files } = commander
261
+ if (!files.length) {
262
+ files = options.patterns || []
263
+ }
180
264
  if (files.length) {
181
- for (let i = 0; i < files.length; i++) {
182
- processSources(files[i], false)
265
+ const dynamic = files.some(file => isDynamicPattern(file))
266
+ if (dynamic) {
267
+ processPatterns(files)
268
+ } else {
269
+ for (const file of files) {
270
+ processSource(file, false)
271
+ }
183
272
  }
184
273
  } else {
274
+ let source = ''
185
275
  const stdin = process.openStdin()
186
276
  stdin.setEncoding('utf8')
187
- stdin.on('data', function (chunk) {
277
+ stdin.on('data', chunk => {
188
278
  source += chunk.toString('utf8')
189
279
  })
190
- stdin.on('end', function () {
191
- const parsed = parse(source, '<stdin>')
192
- if (!options.quiet) {
280
+ stdin.on('end', () => {
281
+ if (options.logFiles) {
282
+ console.log('<stdin>')
283
+ }
284
+ const parsed = processContents(source, '<stdin>')
285
+ if (!(options.quiet || options.logFiles)) {
193
286
  console.log(parsed)
194
287
  }
195
288
  })
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@prantlf/jsonlint",
3
- "version": "11.1.0",
3
+ "version": "11.3.0",
4
4
  "description": "JSON/CJSON/JSON5 parser, syntax and schema validator and pretty-printer.",
5
5
  "author": "Ferdinand Prantl <prantlf@gmail.com> (http://prantl.tk)",
6
6
  "contributors": [
7
+ "Ondrej Medek <xmedeko@gmail.com>",
7
8
  "Greg Inman <ginman@itriagehealth.com>",
8
9
  "Paul Vollmer <mail@paulvollmer.net> (http://paulvollmer.net)",
9
10
  "Zach Carter <zach@carter.name> (http://zaa.ch)"
@@ -44,7 +45,7 @@
44
45
  "build": "npm run compile && npm run compile:tests",
45
46
  "compile": "node scripts/bundle-jsonlint && terser -o web/jsonlint.min.js --source-map \"filename='jsonlint.js',url='jsonlint.min.js.map',includeSources=true\" lib/jsonlint.js && terser -o web/validator.min.js --source-map \"filename='validator.js',url='validator.min.js.map',includeSources=true\" lib/validator.js && terser -o web/formatter.min.js --source-map \"filename='formatter.js',url='formatter.min.js.map',includeSources=true\" lib/formatter.js && terser -o web/sorter.min.js --source-map \"filename='sorter.js',url='sorter.min.js.map',includeSources=true\" lib/sorter.js && terser -o web/printer.min.js --source-map \"filename='printer.js',url='printer.min.js.map',includeSources=true\" lib/printer.js && node scripts/bundle-schema-drafts && terser -o web/schema-drafts.min.js --source-map \"filename='schema-drafts.js',url='schema-drafts.min.js.map',includeSources=true\" lib/schema-drafts.js && terser -o web/ajv.min.js --source-map \"filename='ajv.js',url='ajv.min.js.map',includeSources=true\" node_modules/ajv/dist/ajv.bundle.js",
46
47
  "compile:tests": "tsc --lib es6 test/typings.test.ts",
47
- "test": "nyc --silent node test/typings.test.js && nyc --silent --no-clean node test/parse1 && nyc --silent --no-clean node test/parse1 --native-parser && nyc --silent --no-clean node test/parse2 && nyc --silent --no-clean node test/parse3 && nyc --silent --no-clean node test/parse4 && nyc --silent --no-clean node test/parse5 && nyc --silent --no-clean node test/portable && nyc --silent --no-clean node test/tokenize && nyc --silent --no-clean node test/print && nyc --silent --no-clean node lib/cli package.json test/recursive && nyc --silent --no-clean node lib/cli -sq test/passes/hasOwnProperty.json && nyc --silent --no-clean node lib/cli -s -e json-schema-draft-04 -V test/passes/3.schema.json test/passes/3.json && nyc --silent --no-clean node lib/cli -C test/passes/comments.txt && nyc --silent --no-clean node lib/cli -pS test/passes/strings.txt && nyc --silent --no-clean node lib/cli -M json5 test/passes/json5.text && nyc --silent --no-clean node lib/cli -v && nyc --silent --no-clean node lib/cli -h && nyc --silent --no-clean node lib/cli -Pc test/fails/10.json || nyc report",
48
+ "test": "nyc --silent node test/typings.test.js && nyc --silent --no-clean node test/parse1 && nyc --silent --no-clean node test/parse1 --native-parser && nyc --silent --no-clean node test/parse2 && nyc --silent --no-clean node test/parse3 && nyc --silent --no-clean node test/parse4 && nyc --silent --no-clean node test/parse5 && nyc --silent --no-clean node test/portable && nyc --silent --no-clean node test/tokenize && nyc --silent --no-clean node test/print && nyc --silent --no-clean node lib/cli package.json test/recursive && nyc --silent --no-clean node lib/cli -sq test/passes/hasOwnProperty.json && nyc --silent --no-clean node lib/cli -s -e json-schema-draft-04 -V test/passes/3.schema.json test/passes/3.json && nyc --silent --no-clean node lib/cli -C test/passes/comments.txt && nyc --silent --no-clean node lib/cli -pS test/passes/strings.txt && nyc --silent --no-clean node lib/cli -M json5 test/passes/json5.text && nyc --silent --no-clean node lib/cli -v && nyc --silent --no-clean node lib/cli -h && nyc --silent --no-clean node lib/cli -Pc test/fails/10.json || nyc --silent --no-clean node lib/cli -f test/.jsonrc.yml 'test/**/*.json' '!**/fails' && nyc report",
48
49
  "start": "http-server -c 5",
49
50
  "web": "npm run web:sync && npm run web:deploy",
50
51
  "web:clone": "test ! -d ../jsonlint-pages && git clone --single-branch --branch gh-pages `git remote get-url origin` ../jsonlint-pages",
@@ -58,28 +59,30 @@
58
59
  "text"
59
60
  ]
60
61
  },
61
- "standard": {
62
- "ignore": [
63
- "benchmarks/jison",
64
- "benchmarks/pegjs",
65
- "jsonlint*.js",
66
- "test/fails",
67
- "test/passes",
68
- "test/recursive",
69
- "test/v8"
62
+ "release": {
63
+ "plugins": [
64
+ "@semantic-release/commit-analyzer",
65
+ "@semantic-release/release-notes-generator",
66
+ "@semantic-release/changelog",
67
+ "@semantic-release/npm",
68
+ [
69
+ "@semantic-release/github",
70
+ {
71
+ "failComment": false
72
+ }
73
+ ],
74
+ "@semantic-release/git"
70
75
  ]
71
76
  },
72
- "keywords": [
73
- "json",
74
- "validation",
75
- "lint",
76
- "jsonlint"
77
- ],
78
77
  "dependencies": {
79
78
  "ajv": "6.12.6",
80
- "commander": "9.2.0"
79
+ "commander": "9.2.0",
80
+ "cosmiconfig": "^7.0.1",
81
+ "fast-glob": "3.2.11"
81
82
  },
82
83
  "devDependencies": {
84
+ "@semantic-release/changelog": "^6.0.1",
85
+ "@semantic-release/git": "^10.0.1",
83
86
  "@types/node": "17.0.30",
84
87
  "@typescript-eslint/eslint-plugin": "5.21.0",
85
88
  "@typescript-eslint/parser": "5.21.0",
@@ -94,5 +97,11 @@
94
97
  "terser": "5.13.1",
95
98
  "test": "0.6.0",
96
99
  "typescript": "4.6.4"
97
- }
100
+ },
101
+ "keywords": [
102
+ "json",
103
+ "validation",
104
+ "lint",
105
+ "jsonlint"
106
+ ]
98
107
  }
package/web/jsonlint.html CHANGED
@@ -79,7 +79,7 @@
79
79
  <body>
80
80
  <header>
81
81
  <h1>JSON Lint</h1>
82
- <p>Enter data and optionally schema in the form below to validate them. A pure JavaScript version of the service provided at <a href="http://jsonlint.com/">jsonlint.com</a>.</p>
82
+ <p>Enter data and optionally schema in the form below to validate them.</p>
83
83
  </header>
84
84
  <main>
85
85
  <section>
@@ -111,7 +111,7 @@
111
111
  </div>
112
112
  <div>
113
113
  <input type="checkbox" checked id="duplicate-object-keys">
114
- <label for="single-quoted-strings">Allow duplicate object keys</label>
114
+ <label for="duplicate-object-keys">Allow duplicate object keys</label>
115
115
  </div>
116
116
  </div>
117
117
  <div>
@@ -179,7 +179,7 @@
179
179
  </main>
180
180
  <hr>
181
181
  <footer>
182
- <small>Copyright &copy; 2012-2019 Zachary Carter, Ferdinand Prantl. See the <a href="https://github.com/prantlf/jsonlint#json-lint">project pages</a> to learn about command-line validation and programmatic usage.</small>
182
+ <small>Copyright &copy; 2012-2022 Zachary Carter, Ferdinand Prantl. See the <a href="https://github.com/prantlf/jsonlint#json-lint">project pages</a> to learn about command-line validation and programmatic usage.</small>
183
183
  <!-- See http://tholman.com/github-corners/ -->
184
184
  <a href="http://github.com/prantlf/jsonlint" class="github-corner" title="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
185
185
  </footer>