@stoplight/spectral-core 1.5.1 → 1.6.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/dist/guards/isAggregateError.d.ts +3 -0
- package/dist/guards/isAggregateError.js +9 -0
- package/dist/guards/isAggregateError.js.map +1 -0
- package/dist/meta/rule.schema.json +4 -4
- package/dist/meta/ruleset.schema.json +47 -10
- package/dist/meta/shared.json +5 -2
- package/dist/ruleset/rule/rule.d.ts +6 -5
- package/dist/ruleset/rule/rule.js +45 -11
- package/dist/ruleset/rule/rule.js.map +1 -1
- package/dist/ruleset/ruleset.d.ts +4 -3
- package/dist/ruleset/ruleset.js +23 -5
- package/dist/ruleset/ruleset.js.map +1 -1
- package/dist/ruleset/types.d.ts +9 -1
- package/dist/ruleset/utils/formatsSet.d.ts +4 -0
- package/dist/ruleset/utils/formatsSet.js +14 -0
- package/dist/ruleset/utils/formatsSet.js.map +1 -0
- package/dist/ruleset/validation.js +2 -2
- package/dist/ruleset/validation.js.map +1 -1
- package/dist/runner/runner.js +14 -12
- package/dist/runner/runner.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAggregateError = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
function isAggregateError(maybeAggregateError) {
|
|
6
|
+
return lodash_1.isError(maybeAggregateError) && maybeAggregateError.constructor.name === 'AggregateError';
|
|
7
|
+
}
|
|
8
|
+
exports.isAggregateError = isAggregateError;
|
|
9
|
+
//# sourceMappingURL=isAggregateError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isAggregateError.js","sourceRoot":"","sources":["../../src/guards/isAggregateError.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAEjC,SAAgB,gBAAgB,CAAC,mBAA4B;IAC3D,OAAO,gBAAO,CAAC,mBAAmB,CAAC,IAAI,mBAAmB,CAAC,WAAW,CAAC,IAAI,KAAK,gBAAgB,CAAC;AACnG,CAAC;AAFD,4CAEC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "
|
|
3
|
+
"$id": "@stoplight/spectral-core/meta/rule.schema",
|
|
4
4
|
"$defs": {
|
|
5
5
|
"Then": {
|
|
6
6
|
"type": "object",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"Severity": {
|
|
23
|
-
"$ref": "shared
|
|
23
|
+
"$ref": "shared#severity"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"oneOf": [
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"type": "array"
|
|
67
67
|
},
|
|
68
68
|
"formats": {
|
|
69
|
-
"$ref": "shared
|
|
69
|
+
"$ref": "shared#formats"
|
|
70
70
|
},
|
|
71
71
|
"then": {
|
|
72
72
|
"anyOf": [
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
|
-
"$ref": "shared
|
|
98
|
+
"$ref": "shared#/$defs/HumanReadableSeverity"
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
"type": "boolean"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "
|
|
3
|
+
"$id": "@stoplight/spectral-core/meta/ruleset.schema",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"additionalProperties": false,
|
|
6
6
|
"properties": {
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"rules": {
|
|
13
13
|
"type": "object",
|
|
14
14
|
"additionalProperties": {
|
|
15
|
-
"$ref": "rule.schema
|
|
15
|
+
"$ref": "rule.schema#"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"formats": {
|
|
19
|
-
"$ref": "shared
|
|
19
|
+
"$ref": "shared#formats"
|
|
20
20
|
},
|
|
21
21
|
"extends": {
|
|
22
22
|
"oneOf": [
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"type": "object",
|
|
57
57
|
"properties": {
|
|
58
58
|
"duplicateKeys": {
|
|
59
|
-
"$ref": "shared
|
|
59
|
+
"$ref": "shared#severity"
|
|
60
60
|
},
|
|
61
61
|
"incompatibleValues": {
|
|
62
|
-
"$ref": "shared
|
|
62
|
+
"$ref": "shared#severity"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"additionalProperties": false
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"rules": {
|
|
92
92
|
"type": "object",
|
|
93
93
|
"additionalProperties": {
|
|
94
|
-
"$ref": "shared
|
|
94
|
+
"$ref": "shared#severity"
|
|
95
95
|
},
|
|
96
96
|
"errorMessage": {
|
|
97
97
|
"enum": "must be a valid severity level"
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"type": "object",
|
|
131
131
|
"properties": {
|
|
132
132
|
"formats": {
|
|
133
|
-
"$ref": "
|
|
133
|
+
"$ref": "shared#formats"
|
|
134
134
|
},
|
|
135
135
|
"extends": {
|
|
136
136
|
"$ref": "#/properties/extends"
|
|
@@ -171,9 +171,46 @@
|
|
|
171
171
|
}
|
|
172
172
|
},
|
|
173
173
|
"additionalProperties": {
|
|
174
|
-
"
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
"oneOf": [
|
|
175
|
+
{
|
|
176
|
+
"$id": "alias-value",
|
|
177
|
+
"type": "string",
|
|
178
|
+
"pattern": "^[$#]",
|
|
179
|
+
"errorMessage": {
|
|
180
|
+
"_": "the value of an alias must be a valid JSON Path expression, a reference to the existing Alias optionally paired with a JSON Path expression subset, or contain a valid set of targets",
|
|
181
|
+
"pattern": "the value of an alias must be a valid JSON Path expression or a reference to the existing Alias optionally paired with a JSON Path expression subset"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"type": "object",
|
|
186
|
+
"properties": {
|
|
187
|
+
"description": {
|
|
188
|
+
"type": "string"
|
|
189
|
+
},
|
|
190
|
+
"targets": {
|
|
191
|
+
"type": "array",
|
|
192
|
+
"minItems": 1,
|
|
193
|
+
"items": {
|
|
194
|
+
"type": "object",
|
|
195
|
+
"properties": {
|
|
196
|
+
"formats": {
|
|
197
|
+
"$ref": "shared#formats"
|
|
198
|
+
},
|
|
199
|
+
"given": {
|
|
200
|
+
"$ref": "alias-value"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"required": ["formats", "given"],
|
|
204
|
+
"errorMessage": "a valid target must contain given and non-empty formats"
|
|
205
|
+
},
|
|
206
|
+
"errorMessage": {
|
|
207
|
+
"minItems": "targets must have at least a single alias definition"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"required": ["targets"]
|
|
212
|
+
}
|
|
213
|
+
]
|
|
177
214
|
}
|
|
178
215
|
}
|
|
179
216
|
},
|
package/dist/meta/shared.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "
|
|
3
|
+
"$id": "@stoplight/spectral-core/meta/shared",
|
|
4
4
|
"$defs": {
|
|
5
5
|
"Formats": {
|
|
6
|
+
"$anchor": "formats",
|
|
6
7
|
"type": "array",
|
|
7
8
|
"items": {
|
|
8
|
-
"$ref": "
|
|
9
|
+
"$ref": "#format"
|
|
9
10
|
},
|
|
10
11
|
"errorMessage": "must be an array of formats"
|
|
11
12
|
},
|
|
12
13
|
"Format": {
|
|
14
|
+
"$anchor": "format",
|
|
13
15
|
"spectral-runtime": "spectral-format",
|
|
14
16
|
"errorMessage": "must be a valid format"
|
|
15
17
|
},
|
|
@@ -20,6 +22,7 @@
|
|
|
20
22
|
"enum": ["error", "warn", "info", "hint", "off"]
|
|
21
23
|
},
|
|
22
24
|
"Severity": {
|
|
25
|
+
"$anchor": "severity",
|
|
23
26
|
"oneOf": [
|
|
24
27
|
{
|
|
25
28
|
"$ref": "#/$defs/DiagnosticSeverity"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { JsonPath, Optional } from '@stoplight/types';
|
|
2
|
-
import { DiagnosticSeverity } from '@stoplight/types';
|
|
1
|
+
import { JsonPath, Optional, DiagnosticSeverity } from '@stoplight/types';
|
|
3
2
|
import { Ruleset } from '../ruleset';
|
|
4
3
|
import { Format } from '../format';
|
|
5
|
-
import { HumanReadableDiagnosticSeverity, IRuleThen, RuleDefinition } from '../types';
|
|
4
|
+
import type { HumanReadableDiagnosticSeverity, IRuleThen, RuleDefinition } from '../types';
|
|
5
|
+
import { FormatsSet } from '../utils/formatsSet';
|
|
6
6
|
export interface IRule {
|
|
7
7
|
description: string | null;
|
|
8
8
|
message: string | null;
|
|
@@ -17,7 +17,7 @@ export interface IRule {
|
|
|
17
17
|
}
|
|
18
18
|
export declare type StringifiedRule = Omit<IRule, 'formats' | 'then'> & {
|
|
19
19
|
name: string;
|
|
20
|
-
formats:
|
|
20
|
+
formats: FormatsSet | null;
|
|
21
21
|
then: (Pick<IRuleThen, 'field'> & {
|
|
22
22
|
function: string;
|
|
23
23
|
functionOptions?: string;
|
|
@@ -32,7 +32,7 @@ export declare class Rule implements IRule {
|
|
|
32
32
|
description: string | null;
|
|
33
33
|
message: string | null;
|
|
34
34
|
resolved: boolean;
|
|
35
|
-
formats:
|
|
35
|
+
formats: FormatsSet | null;
|
|
36
36
|
recommended: boolean;
|
|
37
37
|
documentationUrl: string | null;
|
|
38
38
|
constructor(name: string, definition: RuleDefinition, owner: Ruleset);
|
|
@@ -49,6 +49,7 @@ export declare class Rule implements IRule {
|
|
|
49
49
|
set then(then: RuleDefinition['then']);
|
|
50
50
|
get given(): string[];
|
|
51
51
|
set given(given: RuleDefinition['given']);
|
|
52
|
+
getGivenForFormats(formats: Set<Format<any>> | null): string[];
|
|
52
53
|
matchesFormat(formats: Set<Format> | null): boolean;
|
|
53
54
|
clone(): Rule;
|
|
54
55
|
toJSON(): StringifiedRule;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _Rule_instances, _Rule_severity, _Rule_enabled, _Rule_then, _Rule_given, _Rule_resolveAlias;
|
|
2
|
+
var _Rule_instances, _Rule_severity, _Rule_enabled, _Rule_then, _Rule_given, _Rule_resolveAlias, _Rule_resolveAliasForFormats;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Rule = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
6
7
|
const path_1 = require("@stoplight/path");
|
|
7
8
|
const json_1 = require("@stoplight/json");
|
|
9
|
+
const spectral_runtime_1 = require("@stoplight/spectral-runtime");
|
|
8
10
|
const severity_1 = require("../utils/severity");
|
|
9
11
|
const minimatch_1 = require("../utils/minimatch");
|
|
10
|
-
const
|
|
12
|
+
const formatsSet_1 = require("../utils/formatsSet");
|
|
11
13
|
const ALIAS = /^#([A-Za-z0-9_-]+)/;
|
|
12
14
|
class Rule {
|
|
13
15
|
constructor(name, definition, owner) {
|
|
@@ -27,7 +29,7 @@ class Rule {
|
|
|
27
29
|
this.documentationUrl = (_c = definition.documentationUrl) !== null && _c !== void 0 ? _c : null;
|
|
28
30
|
this.severity = definition.severity;
|
|
29
31
|
this.resolved = definition.resolved !== false;
|
|
30
|
-
this.formats = 'formats' in definition ? new
|
|
32
|
+
this.formats = 'formats' in definition ? new formatsSet_1.FormatsSet(definition.formats) : null;
|
|
31
33
|
this.then = definition.then;
|
|
32
34
|
this.given = definition.given;
|
|
33
35
|
}
|
|
@@ -82,10 +84,18 @@ class Rule {
|
|
|
82
84
|
tslib_1.__classPrivateFieldSet(this, _Rule_then, Array.isArray(then) ? then : [then], "f");
|
|
83
85
|
}
|
|
84
86
|
get given() {
|
|
85
|
-
return tslib_1.__classPrivateFieldGet(this, _Rule_given, "f")
|
|
87
|
+
return tslib_1.__classPrivateFieldGet(this, _Rule_given, "f");
|
|
86
88
|
}
|
|
87
89
|
set given(given) {
|
|
88
|
-
|
|
90
|
+
const actualGiven = Array.isArray(given) ? given : [given];
|
|
91
|
+
tslib_1.__classPrivateFieldSet(this, _Rule_given, this.owner.hasComplexAliases
|
|
92
|
+
? actualGiven
|
|
93
|
+
: actualGiven.map(expr => tslib_1.__classPrivateFieldGet(this, _Rule_instances, "m", _Rule_resolveAlias).call(this, expr, null)).filter(lodash_1.isString), "f");
|
|
94
|
+
}
|
|
95
|
+
getGivenForFormats(formats) {
|
|
96
|
+
return this.owner.hasComplexAliases
|
|
97
|
+
? tslib_1.__classPrivateFieldGet(this, _Rule_given, "f").map(expr => tslib_1.__classPrivateFieldGet(this, _Rule_instances, "m", _Rule_resolveAlias).call(this, expr, formats)).filter(lodash_1.isString)
|
|
98
|
+
: tslib_1.__classPrivateFieldGet(this, _Rule_given, "f");
|
|
89
99
|
}
|
|
90
100
|
matchesFormat(formats) {
|
|
91
101
|
if (this.formats === null) {
|
|
@@ -114,19 +124,19 @@ class Rule {
|
|
|
114
124
|
documentationUrl: this.documentationUrl,
|
|
115
125
|
severity: this.severity,
|
|
116
126
|
resolved: this.resolved,
|
|
117
|
-
formats: this.formats
|
|
127
|
+
formats: this.formats,
|
|
118
128
|
then: this.then.map(then => ({
|
|
119
129
|
...then.function,
|
|
120
130
|
function: then.function.name,
|
|
121
131
|
...('functionOptions' in then ? { functionOptions: spectral_runtime_1.printValue(then.functionOptions) } : null),
|
|
122
132
|
})),
|
|
123
|
-
given:
|
|
133
|
+
given: Array.isArray(this.definition.given) ? this.definition.given : [this.definition.given],
|
|
124
134
|
owner: this.owner.id,
|
|
125
135
|
};
|
|
126
136
|
}
|
|
127
137
|
}
|
|
128
138
|
exports.Rule = Rule;
|
|
129
|
-
_Rule_severity = new WeakMap(), _Rule_enabled = new WeakMap(), _Rule_then = new WeakMap(), _Rule_given = new WeakMap(), _Rule_instances = new WeakSet(), _Rule_resolveAlias = function _Rule_resolveAlias(expr) {
|
|
139
|
+
_Rule_severity = new WeakMap(), _Rule_enabled = new WeakMap(), _Rule_then = new WeakMap(), _Rule_given = new WeakMap(), _Rule_instances = new WeakSet(), _Rule_resolveAlias = function _Rule_resolveAlias(expr, formats) {
|
|
130
140
|
var _a;
|
|
131
141
|
let resolvedExpr = expr;
|
|
132
142
|
const stack = new Set();
|
|
@@ -143,13 +153,37 @@ _Rule_severity = new WeakMap(), _Rule_enabled = new WeakMap(), _Rule_then = new
|
|
|
143
153
|
if (this.owner.aliases === null || !(alias in this.owner.aliases)) {
|
|
144
154
|
throw new ReferenceError(`Alias "${alias}" does not exist`);
|
|
145
155
|
}
|
|
146
|
-
|
|
147
|
-
|
|
156
|
+
const aliasValue = this.owner.aliases[alias];
|
|
157
|
+
let actualAliasValue;
|
|
158
|
+
if (typeof aliasValue === 'string') {
|
|
159
|
+
actualAliasValue = aliasValue;
|
|
148
160
|
}
|
|
149
161
|
else {
|
|
150
|
-
|
|
162
|
+
actualAliasValue = tslib_1.__classPrivateFieldGet(this, _Rule_instances, "m", _Rule_resolveAliasForFormats).call(this, aliasValue, formats);
|
|
163
|
+
}
|
|
164
|
+
if (actualAliasValue === null) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
if (actualAliasValue.length + 1 === expr.length) {
|
|
168
|
+
resolvedExpr = actualAliasValue;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
resolvedExpr = actualAliasValue + resolvedExpr.slice(alias.length + 1);
|
|
151
172
|
}
|
|
152
173
|
}
|
|
153
174
|
return resolvedExpr;
|
|
175
|
+
}, _Rule_resolveAliasForFormats = function _Rule_resolveAliasForFormats({ targets }, formats) {
|
|
176
|
+
if (formats === null || formats.size === 0) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
for (let i = targets.length - 1; i >= 0; i--) {
|
|
180
|
+
const target = targets[i];
|
|
181
|
+
for (const format of target.formats) {
|
|
182
|
+
if (formats.has(format)) {
|
|
183
|
+
return target.given;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
154
188
|
};
|
|
155
189
|
//# sourceMappingURL=rule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../../../src/ruleset/rule/rule.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../../../src/ruleset/rule/rule.ts"],"names":[],"mappings":";;;;;AAAA,mCAAkC;AAElC,0CAAoD;AACpD,0CAAgD;AAChD,kEAAyD;AAEzD,gDAAkF;AASlF,kDAA+C;AAC/C,oDAAiD;AAEjD,MAAM,KAAK,GAAG,oBAAoB,CAAC;AAsBnC,MAAa,IAAI;IAYf,YACkB,IAAY,EACZ,UAA0B,EAC1B,KAAc;;QAFd,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAgB;QAC1B,UAAK,GAAL,KAAK,CAAS;;QAZhC,iCAA+B;QAG/B,gCAAkB;QAGlB,6BAAoB;QACpB,8BAAkB;QAOhB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,KAAK,KAAK,CAAC;QACpD,+BAAA,IAAI,iBAAY,IAAI,CAAC,WAAW,MAAA,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,MAAA,UAAU,CAAC,WAAW,mCAAI,IAAI,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,MAAA,UAAU,CAAC,OAAO,mCAAI,IAAI,CAAC;QAC1C,IAAI,CAAC,gBAAgB,GAAG,MAAA,UAAU,CAAC,gBAAgB,mCAAI,IAAI,CAAC;QAC5D,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,UAAU,CA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,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;YACnC,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBACvB,OAAO,MAAM,CAAC,KAAK,CAAC;aACrB;SACF;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Rule, StringifiedRule } from './rule/rule';
|
|
2
2
|
import { FileRulesetSeverityDefinition, ParserOptions, RulesetAliasesDefinition, RulesetDefinition, RulesetOverridesDefinition } from './types';
|
|
3
|
-
import {
|
|
3
|
+
import { FormatsSet } from './utils/formatsSet';
|
|
4
4
|
declare const STACK_SYMBOL: unique symbol;
|
|
5
5
|
declare type RulesetContext = {
|
|
6
6
|
readonly severity?: FileRulesetSeverityDefinition;
|
|
@@ -12,7 +12,7 @@ export declare type StringifiedRuleset = {
|
|
|
12
12
|
extends: StringifiedRuleset[] | null;
|
|
13
13
|
source: string | null;
|
|
14
14
|
aliases: RulesetAliasesDefinition | null;
|
|
15
|
-
formats:
|
|
15
|
+
formats: FormatsSet | null;
|
|
16
16
|
rules: Record<string, StringifiedRule>;
|
|
17
17
|
overrides: RulesetOverridesDefinition | null;
|
|
18
18
|
parserOptions: ParserOptions;
|
|
@@ -22,9 +22,10 @@ export declare class Ruleset {
|
|
|
22
22
|
readonly maybeDefinition: unknown;
|
|
23
23
|
readonly id: number;
|
|
24
24
|
protected readonly extends: Ruleset[] | null;
|
|
25
|
-
readonly formats:
|
|
25
|
+
readonly formats: FormatsSet<import("./format").Format<void>>;
|
|
26
26
|
readonly overrides: RulesetOverridesDefinition | null;
|
|
27
27
|
readonly aliases: RulesetAliasesDefinition | null;
|
|
28
|
+
readonly hasComplexAliases: boolean;
|
|
28
29
|
readonly rules: Record<string, Rule>;
|
|
29
30
|
readonly definition: RulesetDefinition;
|
|
30
31
|
constructor(maybeDefinition: unknown, context?: RulesetContext);
|
package/dist/ruleset/ruleset.js
CHANGED
|
@@ -10,6 +10,7 @@ const rules_1 = require("./mergers/rules");
|
|
|
10
10
|
const __1 = require("..");
|
|
11
11
|
const rulesets_1 = require("./mergers/rulesets");
|
|
12
12
|
const json_1 = require("@stoplight/json");
|
|
13
|
+
const formatsSet_1 = require("./utils/formatsSet");
|
|
13
14
|
const STACK_SYMBOL = Symbol('@stoplight/spectral/ruleset/#stack');
|
|
14
15
|
const DEFAULT_RULESET_FILE = /^\.?spectral\.(ya?ml|json|m?js)$/;
|
|
15
16
|
let SEED = 1;
|
|
@@ -19,7 +20,7 @@ class Ruleset {
|
|
|
19
20
|
this.maybeDefinition = maybeDefinition;
|
|
20
21
|
_Ruleset_instances.add(this);
|
|
21
22
|
this.id = SEED++;
|
|
22
|
-
this.formats = new
|
|
23
|
+
this.formats = new formatsSet_1.FormatsSet();
|
|
23
24
|
_Ruleset_context.set(this, void 0);
|
|
24
25
|
let definition;
|
|
25
26
|
if (json_1.isPlainObject(maybeDefinition) && 'extends' in maybeDefinition) {
|
|
@@ -36,7 +37,23 @@ class Ruleset {
|
|
|
36
37
|
severity: 'recommended',
|
|
37
38
|
...context,
|
|
38
39
|
}, "f");
|
|
39
|
-
|
|
40
|
+
let hasComplexAliases = false;
|
|
41
|
+
this.aliases =
|
|
42
|
+
definition.aliases === void 0
|
|
43
|
+
? null
|
|
44
|
+
: Object.fromEntries(Object.entries(definition.aliases).map(alias => {
|
|
45
|
+
const [name, value] = alias;
|
|
46
|
+
if (typeof value === 'string') {
|
|
47
|
+
return alias;
|
|
48
|
+
}
|
|
49
|
+
hasComplexAliases = true;
|
|
50
|
+
const targets = value.targets.map(target => ({
|
|
51
|
+
formats: new formatsSet_1.FormatsSet(target.formats),
|
|
52
|
+
given: target.given,
|
|
53
|
+
}));
|
|
54
|
+
return [name, { ...value, targets }];
|
|
55
|
+
}));
|
|
56
|
+
this.hasComplexAliases = hasComplexAliases;
|
|
40
57
|
const stack = (_a = context === null || context === void 0 ? void 0 : context[STACK_SYMBOL]) !== null && _a !== void 0 ? _a : new Map();
|
|
41
58
|
stack.set(this.definition, this);
|
|
42
59
|
this.extends =
|
|
@@ -165,7 +182,7 @@ class Ruleset {
|
|
|
165
182
|
extends: this.extends,
|
|
166
183
|
source: this.source,
|
|
167
184
|
aliases: this.aliases,
|
|
168
|
-
formats: this.formats.size === 0 ? null :
|
|
185
|
+
formats: this.formats.size === 0 ? null : this.formats,
|
|
169
186
|
rules: this.rules,
|
|
170
187
|
overrides: this.overrides,
|
|
171
188
|
parserOptions: this.parserOptions,
|
|
@@ -198,10 +215,11 @@ _Ruleset_context = new WeakMap(), _Ruleset_instances = new WeakSet(), _Ruleset_g
|
|
|
198
215
|
}
|
|
199
216
|
}
|
|
200
217
|
else if (rule.owner !== this) {
|
|
201
|
-
rule.formats =
|
|
218
|
+
rule.formats =
|
|
219
|
+
rule.owner.definition.formats === void 0 ? null : new formatsSet_1.FormatsSet(rule.owner.definition.formats);
|
|
202
220
|
}
|
|
203
221
|
else if (this.definition.formats !== void 0) {
|
|
204
|
-
rule.formats = new
|
|
222
|
+
rule.formats = new formatsSet_1.FormatsSet(this.definition.formats);
|
|
205
223
|
}
|
|
206
224
|
if (this.definition.documentationUrl !== void 0 && rule.documentationUrl === null) {
|
|
207
225
|
rule.documentationUrl = `${this.definition.documentationUrl}#${name}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruleset.js","sourceRoot":"","sources":["../../src/ruleset/ruleset.ts"],"names":[],"mappings":";;;;;AAAA,0CAAoD;AACpD,iDAA8C;AAS9C,6CAAkD;
|
|
1
|
+
{"version":3,"file":"ruleset.js","sourceRoot":"","sources":["../../src/ruleset/ruleset.ts"],"names":[],"mappings":";;;;;AAAA,0CAAoD;AACpD,iDAA8C;AAS9C,6CAAkD;AAClD,2CAA4C;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AK,IAAI,EAAE;gBAC9B,IAAI,CAAC,OAAO;oBACV,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,uBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aACnG;iBAAM,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,KAAK,KAAK,CAAC,EAAE;gBAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aACxD;YAED,IAAI,IAAI,CAAC,UAAU,CAAC,gBAAgB,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,gBAAgB,KAAK,IAAI,EAAE;gBACjF,IAAI,CAAC,gBAAgB,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC;aACvE;SACF;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/ruleset/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DiagnosticSeverity } from '@stoplight/types';
|
|
2
2
|
import { Format } from './format';
|
|
3
3
|
import { RulesetFunction, RulesetFunctionWithValidator } from '../types';
|
|
4
|
+
import { FormatsSet } from './utils/formatsSet';
|
|
4
5
|
export declare type HumanReadableDiagnosticSeverity = 'error' | 'warn' | 'info' | 'hint' | 'off';
|
|
5
6
|
export declare type FileRuleSeverityDefinition = DiagnosticSeverity | HumanReadableDiagnosticSeverity | boolean;
|
|
6
7
|
export declare type FileRulesetSeverityDefinition = 'off' | 'recommended' | 'all';
|
|
@@ -38,7 +39,14 @@ export declare type RulesetOverrideDefinition = Pick<RulesetDefinition, 'formats
|
|
|
38
39
|
export declare type RulesetOverridesDefinition = ReadonlyArray<{
|
|
39
40
|
files: string[];
|
|
40
41
|
} & RulesetOverrideDefinition>;
|
|
41
|
-
export declare type
|
|
42
|
+
export declare type RulesetScopedAliasDefinition = {
|
|
43
|
+
description?: string;
|
|
44
|
+
targets: {
|
|
45
|
+
formats: FormatsSet;
|
|
46
|
+
given: string;
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
49
|
+
export declare type RulesetAliasesDefinition = Record<string, string | RulesetScopedAliasDefinition>;
|
|
42
50
|
export declare type RulesetDefinition = Readonly<{
|
|
43
51
|
documentationUrl?: string;
|
|
44
52
|
formats?: Format<any>[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormatsSet = void 0;
|
|
4
|
+
function printFormat(format) {
|
|
5
|
+
var _a;
|
|
6
|
+
return (_a = format.displayName) !== null && _a !== void 0 ? _a : format.name;
|
|
7
|
+
}
|
|
8
|
+
class FormatsSet extends Set {
|
|
9
|
+
toJSON() {
|
|
10
|
+
return Array.from(this).map(printFormat);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.FormatsSet = FormatsSet;
|
|
14
|
+
//# sourceMappingURL=formatsSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatsSet.js","sourceRoot":"","sources":["../../../src/ruleset/utils/formatsSet.ts"],"names":[],"mappings":";;;AAEA,SAAS,WAAW,CAAC,MAAc;;IACjC,OAAO,MAAA,MAAM,CAAC,WAAW,mCAAI,MAAM,CAAC,IAAI,CAAC;AAC3C,CAAC;AAED,MAAa,UAAsC,SAAQ,GAAM;IACxD,MAAM;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;CACF;AAJD,gCAIC"}
|
|
@@ -10,7 +10,7 @@ const ruleSchema = require("../meta/rule.schema.json");
|
|
|
10
10
|
const rulesetSchema = require("../meta/ruleset.schema.json");
|
|
11
11
|
const shared = require("../meta/shared.json");
|
|
12
12
|
const message = ajv_1._ `'spectral-message'`;
|
|
13
|
-
const ajv = new ajv_1.default({ allErrors: true, strict: true, strictRequired: false });
|
|
13
|
+
const ajv = new ajv_1.default({ allErrors: true, strict: true, strictRequired: false, keywords: ['$anchor'] });
|
|
14
14
|
ajv_formats_1.default(ajv);
|
|
15
15
|
ajv_errors_1.default(ajv);
|
|
16
16
|
ajv.addKeyword({
|
|
@@ -43,7 +43,7 @@ class RulesetValidationError extends Error {
|
|
|
43
43
|
}
|
|
44
44
|
exports.RulesetValidationError = RulesetValidationError;
|
|
45
45
|
const RULE_INSTANCE_PATH = /^\/rules\/[^/]+/;
|
|
46
|
-
const GENERIC_INSTANCE_PATH = /^\/(?:extends|overrides(?:\/\d+\/extends)?)/;
|
|
46
|
+
const GENERIC_INSTANCE_PATH = /^\/(?:aliases|extends|overrides(?:\/\d+\/extends)?)/;
|
|
47
47
|
class RulesetAjvValidationError extends RulesetValidationError {
|
|
48
48
|
constructor(ruleset, errors) {
|
|
49
49
|
super(RulesetAjvValidationError.serializeAjvErrors(ruleset, errors));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/ruleset/validation.ts"],"names":[],"mappings":";;;AAAA,6BAA0C;AAC1C,6CAAqC;AACrC,2CAAmC;AACnC,0CAAgD;AAChD,kEAAoE;AAEpE,uDAAuD;AACvD,6DAA6D;AAC7D,8CAA8C;AAG9C,MAAM,OAAO,GAAG,OAAC,CAAA,oBAAoB,CAAC;AAEtC,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/ruleset/validation.ts"],"names":[],"mappings":";;;AAAA,6BAA0C;AAC1C,6CAAqC;AACrC,2CAAmC;AACnC,0CAAgD;AAChD,kEAAoE;AAEpE,u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,6BAAU,CAAC,OAAO,CAAC,KAAK,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EAAE,CAClG;aACA,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;CACF;AAED,SAAgB,kBAAkB,CAAC,OAAgB;;IACjD,IAAI,CAAC,oBAAa,CAAC,OAAO,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IAED,IAAI,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,IAAI,OAAO,CAAC,EAAE;QACjF,MAAM,IAAI,sBAAsB,CAAC,yDAAyD,CAAC,CAAC;KAC7F;IAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACtB,MAAM,IAAI,yBAAyB,CAAC,OAAO,EAAE,MAAA,QAAQ,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC;KACrE;AACH,CAAC;AAZD,gDAYC;AAED,SAAgB,WAAW,CAAC,IAAwB;IAClD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,CAAC,CAAC;AAClH,CAAC;AAFD,kCAEC;AAED,SAAgB,eAAe,CAAC,IAAwB;IACtD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;QACtB,MAAM,IAAI,SAAS,CAAC,cAAc,CAAC,CAAC;KACrC;AACH,CAAC;AAJD,0CAIC"}
|
package/dist/runner/runner.js
CHANGED
|
@@ -6,7 +6,7 @@ const lintNode_1 = require("./lintNode");
|
|
|
6
6
|
const legacy_1 = require("nimma/legacy");
|
|
7
7
|
const fallbacks_1 = require("nimma/fallbacks");
|
|
8
8
|
const json_1 = require("@stoplight/json");
|
|
9
|
-
const
|
|
9
|
+
const isAggregateError_1 = require("../guards/isAggregateError");
|
|
10
10
|
class Runner {
|
|
11
11
|
constructor(runtime, inventory) {
|
|
12
12
|
var _a;
|
|
@@ -21,11 +21,12 @@ class Runner {
|
|
|
21
21
|
this.results.push(result);
|
|
22
22
|
}
|
|
23
23
|
async run(ruleset) {
|
|
24
|
-
var _a;
|
|
25
|
-
var
|
|
24
|
+
var _a, _b;
|
|
25
|
+
var _c;
|
|
26
26
|
this.runtime.emit('setup');
|
|
27
27
|
const { inventory: documentInventory } = this;
|
|
28
28
|
const { rules } = ruleset;
|
|
29
|
+
const formats = (_a = this.document.formats) !== null && _a !== void 0 ? _a : null;
|
|
29
30
|
const runnerContext = {
|
|
30
31
|
ruleset,
|
|
31
32
|
documentInventory,
|
|
@@ -39,16 +40,20 @@ class Runner {
|
|
|
39
40
|
unresolved: {},
|
|
40
41
|
};
|
|
41
42
|
for (const rule of relevantRules) {
|
|
42
|
-
for (const given of rule.
|
|
43
|
+
for (const given of rule.getGivenForFormats(formats)) {
|
|
43
44
|
const cb = (scope) => {
|
|
44
45
|
lintNode_1.lintNode(runnerContext, scope, rule);
|
|
45
46
|
};
|
|
46
|
-
((
|
|
47
|
+
((_b = (_c = callbacks[rule.resolved ? 'resolved' : 'unresolved'])[given]) !== null && _b !== void 0 ? _b : (_c[given] = [])).push(cb);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const resolvedJsonPaths = Object.keys(callbacks.resolved);
|
|
51
|
+
const unresolvedJsonPaths = Object.keys(callbacks.unresolved);
|
|
52
|
+
if (resolvedJsonPaths.length > 0) {
|
|
53
|
+
execute(runnerContext.documentInventory.resolved, callbacks.resolved, resolvedJsonPaths);
|
|
54
|
+
}
|
|
55
|
+
if (unresolvedJsonPaths.length > 0) {
|
|
56
|
+
execute(runnerContext.documentInventory.unresolved, callbacks.unresolved, unresolvedJsonPaths);
|
|
52
57
|
}
|
|
53
58
|
this.runtime.emit('beforeTeardown');
|
|
54
59
|
try {
|
|
@@ -92,7 +97,7 @@ function execute(input, callbacks, jsonPathExpressions) {
|
|
|
92
97
|
}, {}));
|
|
93
98
|
}
|
|
94
99
|
catch (e) {
|
|
95
|
-
if (isAggregateError(e) && e.errors.length === 1) {
|
|
100
|
+
if (isAggregateError_1.isAggregateError(e) && e.errors.length === 1) {
|
|
96
101
|
throw e.errors[0];
|
|
97
102
|
}
|
|
98
103
|
else {
|
|
@@ -100,7 +105,4 @@ function execute(input, callbacks, jsonPathExpressions) {
|
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
|
-
function isAggregateError(maybeAggregateError) {
|
|
104
|
-
return lodash_1.isError(maybeAggregateError) && maybeAggregateError.constructor.name === 'AggregateError';
|
|
105
|
-
}
|
|
106
108
|
//# sourceMappingURL=runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner/runner.ts"],"names":[],"mappings":";;;AAGA,oCAAkE;AAClE,yCAAsC;AAItC,yCAA+C;AAC/C,+CAA+C;AAC/C,0CAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runner/runner.ts"],"names":[],"mappings":";;;AAGA,oCAAkE;AAClE,yCAAsC;AAItC,yCAA+C;AAC/C,+CAA+C;AAC/C,0CAAgD;AAChD,iEAA8D;AAE9D,MAAa,MAAM;IAGjB,YAA+B,OAAsB,EAAqB,SAA4B;;QAAvE,YAAO,GAAP,OAAO,CAAe;QAAqB,cAAS,GAAT,SAAS,CAAmB;QACpG,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,MAAA,IAAI,CAAC,SAAS,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IAED,IAAc,QAAQ;QACpB,OAAO,IAAI,CAAC,SAAS,CAA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