@prantlf/jsonlint 14.0.3 → 14.1.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/lib/sorter.js CHANGED
@@ -6,22 +6,39 @@
6
6
  'use strict'
7
7
 
8
8
  // from http://stackoverflow.com/questions/1359761/sorting-a-json-object-in-javascript
9
- const hasOwnProperty = Object.prototype.hasOwnProperty
10
- function sortObject (o) {
9
+ const ownsProperty = Object.prototype.hasOwnProperty
10
+ function sortObject (o, { ignoreCase, locale, caseFirst, numeric } = {}) {
11
11
  if (Array.isArray(o)) {
12
12
  return o.map(sortObject)
13
- } else if (Object.prototype.toString.call(o) !== '[object Object]') {
13
+ }if (Object.prototype.toString.call(o) !== '[object Object]') {
14
14
  return o
15
15
  }
16
16
  const sorted = {}
17
17
  let key
18
18
  const a = []
19
19
  for (key in o) {
20
- if (hasOwnProperty.call(o, key)) {
20
+ if (ownsProperty.call(o, key)) {
21
21
  a.push(key)
22
22
  }
23
23
  }
24
- a.sort()
24
+ if (locale || caseFirst || numeric) {
25
+ if (locale === 'default') {
26
+ locale = undefined
27
+ }
28
+ const sortOptions = { caseFirst, numeric }
29
+ if (ignoreCase) {
30
+ sortOptions.sensitivity = 'accent'
31
+ }
32
+ a.sort((l, r) => l.localeCompare(r, locale, sortOptions))
33
+ } else if (ignoreCase) {
34
+ a.sort((l, r) => {
35
+ l = l.toLowerCase()
36
+ r = r.toLowerCase()
37
+ return l < r ? -1 : l > r ? 1 : 0
38
+ })
39
+ } else {
40
+ a.sort()
41
+ }
25
42
  for (key = 0; key < a.length; key++) {
26
43
  sorted[a[key]] = sortObject(o[a[key]])
27
44
  }
package/lib/validator.js CHANGED
@@ -63,7 +63,7 @@
63
63
  function errorToProblem (error, input, tokens) {
64
64
  const dataPath = error.dataPath
65
65
  const schemaPath = error.schemaPath
66
- const reason = (dataPath || '/') + ' ' + error.message + '; see ' + schemaPath
66
+ const reason = `${dataPath || '/'} ${error.message}; see ${schemaPath}`
67
67
  const problem = {
68
68
  reason,
69
69
  dataPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prantlf/jsonlint",
3
- "version": "14.0.3",
3
+ "version": "14.1.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": [
@@ -43,7 +43,8 @@
43
43
  "compile:jsonlint": "cat-j src/prefix.js.txt src/unicode.js src/custom-parser.js src/pointer.js src/native-parser.js src/configurable-parser.js src/suffix.js.txt > lib/jsonlint.js",
44
44
  "minify": "esbuild --minify --sourcemap --outfile=web/jsonlint.min.js lib/jsonlint.js && esbuild --minify --sourcemap --outfile=web/validator.min.js lib/validator.js && esbuild --minify --sourcemap --outfile=web/formatter.min.js lib/formatter.js && esbuild --minify --sourcemap --outfile=web/sorter.min.js lib/sorter.js && esbuild --minify --sourcemap --outfile=web/printer.min.js lib/printer.js",
45
45
  "compile:tests": "tsc --moduleResolution node --module es2022 test/types.test.ts && mv-j test/types.test.js test/types.test.mjs",
46
- "test": "denolint && c8 node test/types.test.mjs && c8 --no-clean node test/parse1 && c8 --no-clean node test/parse1 --native-parser && c8 --no-clean node test/parse2 && c8 --no-clean node test/parse3 && c8 --no-clean node test/parse4 && c8 --no-clean node test/parse5 && c8 --no-clean node test/portable && c8 --no-clean node test/tokenize && c8 --no-clean node test/print && c8 --no-clean node lib/cli package.json test/recursive && c8 --no-clean node lib/cli -sq test/passes/hasOwnProperty.json && c8 --no-clean node lib/cli -s -e json-schema-draft-04 -V test/passes/schema-04.json test/passes/data-04.json && c8 --no-clean node lib/cli -s -e json-schema-draft-07 -V test/passes/schema-07.json test/passes/data-07.json && c8 --no-clean node lib/cli -C test/passes/comments.txt && c8 --no-clean node lib/cli -pS test/passes/strings.txt && c8 --no-clean node lib/cli -M json5 test/passes/json5.text && c8 --no-clean node lib/cli -v && c8 --no-clean node lib/cli -h && c8 --no-clean node lib/cli -Pc test/fails/10.json || c8 --no-clean node lib/cli -f test/.jsonrc.yml 'test/**/*.json' '!**/fails' && c8 report -r text -r lcov",
46
+ "lint": "biome lint *.mjs lib src test/*.js",
47
+ "test": "biome lint *.mjs lib src test/*.js && c8 node test/types.test.mjs && c8 --no-clean node test/parse1 && c8 --no-clean node test/parse1 --native-parser && c8 --no-clean node test/parse2 && c8 --no-clean node test/parse3 && c8 --no-clean node test/parse4 && c8 --no-clean node test/parse5 && c8 --no-clean node test/portable && c8 --no-clean node test/tokenize && c8 --no-clean node test/print && c8 --no-clean node lib/cli package.json test/recursive && c8 --no-clean node lib/cli -sq test/passes/hasOwnProperty.json && c8 --no-clean node lib/cli -s -e json-schema-draft-04 -V test/passes/schema-04.json test/passes/data-04.json && c8 --no-clean node lib/cli -s -e json-schema-draft-07 -V test/passes/schema-07.json test/passes/data-07.json && c8 --no-clean node lib/cli -C test/passes/comments.txt && c8 --no-clean node lib/cli -pS test/passes/strings.txt && c8 --no-clean node lib/cli -M json5 test/passes/json5.text && c8 --no-clean node lib/cli -v && c8 --no-clean node lib/cli -h && c8 --no-clean node lib/cli -Pc test/fails/10.json || c8 --no-clean node lib/cli -f test/.jsonrc.yml 'test/**/*.json' '!**/fails' && c8 report -r text -r lcov",
47
48
  "start": "http-server -c 5",
48
49
  "web": "npm run web:sync && npm run web:deploy",
49
50
  "web:clone": "test ! -d ../jsonlint-pages && git clone --single-branch --branch gh-pages `git remote get-url origin` ../jsonlint-pages",
@@ -54,48 +55,31 @@
54
55
  "c8": {
55
56
  "reporter": []
56
57
  },
57
- "release": {
58
- "plugins": [
59
- "@semantic-release/commit-analyzer",
60
- "@semantic-release/release-notes-generator",
61
- "@semantic-release/changelog",
62
- "@semantic-release/npm",
63
- [
64
- "@semantic-release/github",
65
- {
66
- "failComment": false
67
- }
68
- ],
69
- "@semantic-release/git"
70
- ]
71
- },
72
58
  "dependencies": {
73
- "ajv": "8.12.0",
59
+ "ajv": "8.17.1",
74
60
  "ajv-draft-04": "1.0.0",
75
- "cosmiconfig": "8.1.3",
76
- "diff": "5.1.0",
77
- "fast-glob": "3.2.12"
61
+ "cosmiconfig": "9.0.0",
62
+ "diff": "5.2.0",
63
+ "fast-glob": "3.3.2"
78
64
  },
79
65
  "devDependencies": {
80
- "@rollup/plugin-commonjs": "24.1.0",
81
- "@rollup/plugin-json": "6.0.0",
82
- "@rollup/plugin-node-resolve": "15.0.2",
83
- "@semantic-release/changelog": "6.0.3",
84
- "@semantic-release/git": "10.0.1",
85
- "@types/node": "18.16.1",
66
+ "@biomejs/biome": "^1.8.3",
67
+ "@rollup/plugin-commonjs": "26.0.1",
68
+ "@rollup/plugin-json": "6.1.0",
69
+ "@rollup/plugin-node-resolve": "15.2.3",
70
+ "@types/node": "22.1.0",
86
71
  "@unixcompat/cat.js": "2.0.0",
87
72
  "@unixcompat/mv.js": "2.0.0",
88
- "c8": "7.13.0",
89
- "denolint": "2.0.9",
90
- "esbuild": "0.17.18",
73
+ "c8": "10.1.2",
74
+ "esbuild": "0.23.0",
91
75
  "http-server": "14.1.1",
92
76
  "js-yaml": "4.1.0",
93
- "rollup": "3.21.0",
94
- "rollup-plugin-swc-minify": "1.0.6",
77
+ "rollup": "4.20.0",
78
+ "rollup-plugin-swc-minify": "1.1.2",
95
79
  "tehanu": "1.0.1",
96
- "tehanu-repo-coco": "1.0.0",
97
- "tehanu-teru": "1.0.0",
98
- "typescript": "5.0.4"
80
+ "tehanu-repo-coco": "1.0.1",
81
+ "tehanu-teru": "1.0.1",
82
+ "typescript": "5.5.4"
99
83
  },
100
84
  "keywords": [
101
85
  "json",
@@ -103,4 +87,4 @@
103
87
  "lint",
104
88
  "jsonlint"
105
89
  ]
106
- }
90
+ }