@amritk/lint 0.3.0 → 0.3.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 amritk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -220,15 +220,15 @@ The `bench/` suite pits `@amritk/lint` head-to-head against **[Spectral](https:/
220
220
 
221
221
  | document | size | mjst | Spectral | speedup | findings (mjst / Spectral) |
222
222
  | --- | ---: | ---: | ---: | ---: | ---: |
223
- | petstore (Swagger) | 17 KB | ~6 ms | ~124 ms | **~19×** | 2 / 2 |
224
- | digitalocean | 105 KB | ~37 ms | ~477 ms | **~13×** | 3507 / 4319 |
225
- | openai | 2.8 MB | ~1.3 s | errored¹ | — | 1176 / — |
223
+ | petstore (Swagger) | 17 KB | ~7 ms | ~100 ms | **~14×** | 2 / 2 |
224
+ | digitalocean | 105 KB | ~31 ms | ~355 ms | **~12×** | 2411 / 4319 |
225
+ | openai | 2.8 MB | ~1.4 s | errored¹ | — | 1278 / — |
226
226
 
227
227
  ¹ Spectral's JSONPath engine (`nimma`) throws on the 2.8 MB OpenAI spec under Bun, so that row is mjst-only; mjst lints it end to end.
228
228
 
229
229
  Each `lint` figure is the mean wall time of one whole pass — **every rule, not a subset** — dominated by real work: JSONPath matching, the rule functions, and the dereference pass. A fresh document is parsed on every iteration on both sides, matching how the tools are actually called. The finding counts differ because the two rulesets are not byte-identical (different rule implementations and `$ref` resolution), so this is a **throughput** comparison rather than a correctness parity check — but on petstore both land on the same two findings.
230
230
 
231
- **Assembling the ruleset** is timed separately, because a process pays it once and then lints many documents: `createOpenApiRuleset` (compiling every rule's JSONPath and wiring up functions and format detectors) measures **~0.06 ms**, versus **~0.4 ms** for `new Spectral()` + `setRuleset(oas)`. The benchmark warms up before timing and reports the mean over a fixed time budget; micro-benchmark figures vary by machine and runtime.
231
+ **Assembling the ruleset** is timed separately, because a process pays it once and then lints many documents: `createOpenApiRuleset` (compiling every rule's JSONPath and wiring up functions and format detectors) measures **~0.09 ms**, versus **~0.35 ms** for `new Spectral()` + `setRuleset(oas)`. The benchmark warms up before timing and reports the mean over a fixed time budget; micro-benchmark figures vary by machine and runtime.
232
232
 
233
233
  ---
234
234
 
@@ -12,7 +12,7 @@ const compare = (a, b) => {
12
12
  return Math.sign(Number(a) - Number(b));
13
13
  // Match Spectral: when either side is a real number or a numeric string,
14
14
  // compare numerically so mixed inputs like [2, "10"] read as ordered.
15
- if ((typeof a === 'number' || Number.isNaN(Number(a))) && (typeof b === 'number' || !Number.isNaN(Number(b)))) {
15
+ if ((typeof a === 'number' || !Number.isNaN(Number(a))) && (typeof b === 'number' || !Number.isNaN(Number(b)))) {
16
16
  return Math.min(1, Math.max(-1, Number(a) - Number(b)));
17
17
  }
18
18
  if (typeof a !== 'string' || typeof b !== 'string')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amritk/lint",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "A fast, format-agnostic JSON/YAML style-guide linter with JSON Schema and custom rules.",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
@@ -51,12 +51,12 @@
51
51
  }
52
52
  },
53
53
  "dependencies": {
54
- "@amritk/runtime-validators": "0.7.0",
55
- "@amritk/yaml": "0.3.0",
54
+ "@amritk/runtime-validators": "0.7.2",
55
+ "@amritk/yaml": "0.3.2",
56
56
  "jsonc-parser": "^3.3.1"
57
57
  },
58
58
  "devDependencies": {
59
- "@amritk/resolve-refs": "0.4.0",
59
+ "@amritk/resolve-refs": "0.4.2",
60
60
  "@stoplight/spectral-core": "^1.23.1",
61
61
  "@stoplight/spectral-parsers": "^1.0.5",
62
62
  "@stoplight/spectral-rulesets": "^1.22.6"