@amritk/lint 0.4.1 → 0.4.3
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 +1 -1
- package/dist/parsers/yaml.js +16 -8
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ A ruleset is a plain object (authored as YAML, JSON, or a JS module):
|
|
|
164
164
|
| `overrides` | Per-file-glob rule tweaks. |
|
|
165
165
|
| `aliases` | Reusable `given` fragments referenced as `#alias`. |
|
|
166
166
|
|
|
167
|
-
Built-in functions: `alphabetical`, `casing`, `defined`, `enumeration`, `falsy`, `length`, `pattern`, `schema`, `truthy`, `undefined`, `unreferencedReusableObject`, `xor`, `typedEnum`.
|
|
167
|
+
Built-in functions: `alphabetical`, `casing`, `defined`, `enumeration`, `falsy`, `length`, `or`, `pattern`, `schema`, `truthy`, `undefined`, `unreferencedReusableObject`, `xor`, `typedEnum`.
|
|
168
168
|
|
|
169
169
|
---
|
|
170
170
|
|
package/dist/parsers/yaml.js
CHANGED
|
@@ -3,23 +3,31 @@ import { createLineMap } from "./lines.js";
|
|
|
3
3
|
import { DiagnosticSeverity } from "./types.js";
|
|
4
4
|
const pathKey = (path) => path.map((segment) => typeof segment === "number" ? `[${segment}]` : `.${segment}`).join("");
|
|
5
5
|
const serializeComplexKey = (node) => {
|
|
6
|
-
if (isSeq(node))
|
|
7
|
-
return `[${node.items.map(
|
|
6
|
+
if (isSeq(node)) {
|
|
7
|
+
return node.items.length === 0 ? "[]" : `[ ${node.items.map(flowText).join(", ")} ]`;
|
|
8
|
+
}
|
|
8
9
|
if (isMap(node)) {
|
|
9
|
-
|
|
10
|
+
const pairs = node.items.filter(isPair).map((pair) => `${flowText(pair.key)}: ${pair.value ? flowText(pair.value) : "null"}`);
|
|
11
|
+
return pairs.length === 0 ? "{}" : `{ ${pairs.join(", ")} }`;
|
|
12
|
+
}
|
|
13
|
+
return flowText(node);
|
|
14
|
+
};
|
|
15
|
+
const flowText = (node) => {
|
|
16
|
+
if (isScalar(node)) {
|
|
17
|
+
const v = node.value;
|
|
18
|
+
return typeof v === "string" ? v : v === null ? "null" : String(v);
|
|
10
19
|
}
|
|
11
20
|
if (isAlias(node))
|
|
12
|
-
return `*${node.source}`;
|
|
13
|
-
|
|
14
|
-
return typeof v === "string" ? JSON.stringify(v) : v === null ? "null" : String(v);
|
|
21
|
+
return node.target ? flowText(node.target) : `*${node.source}`;
|
|
22
|
+
return serializeComplexKey(node);
|
|
15
23
|
};
|
|
16
24
|
const keyToString = (key) => {
|
|
17
25
|
if (isScalar(key)) {
|
|
18
26
|
const v = key.value;
|
|
19
|
-
return typeof v === "string" ? v : v === null ? "
|
|
27
|
+
return typeof v === "string" ? v : v === null ? "" : String(v);
|
|
20
28
|
}
|
|
21
29
|
if (isAlias(key))
|
|
22
|
-
return `*${key.source}`;
|
|
30
|
+
return key.target ? keyToString(key.target) : `*${key.source}`;
|
|
23
31
|
return serializeComplexKey(key);
|
|
24
32
|
};
|
|
25
33
|
const parseYaml = (source, options = {}) => {
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amritk/lint",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
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",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=20"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "amritk",
|
|
9
13
|
"keywords": [
|
|
@@ -56,12 +60,12 @@
|
|
|
56
60
|
}
|
|
57
61
|
},
|
|
58
62
|
"dependencies": {
|
|
59
|
-
"@amritk/runtime-validators": "0.9.
|
|
60
|
-
"@amritk/yaml": "0.
|
|
63
|
+
"@amritk/runtime-validators": "0.9.1",
|
|
64
|
+
"@amritk/yaml": "0.4.0",
|
|
61
65
|
"jsonc-parser": "^3.3.1"
|
|
62
66
|
},
|
|
63
67
|
"devDependencies": {
|
|
64
|
-
"@amritk/resolve-refs": "0.4.
|
|
68
|
+
"@amritk/resolve-refs": "0.4.5",
|
|
65
69
|
"@stoplight/spectral-core": "^1.23.1",
|
|
66
70
|
"@stoplight/spectral-parsers": "^1.0.5",
|
|
67
71
|
"@stoplight/spectral-rulesets": "^1.22.6"
|