@redocly/openapi-core 1.3.0 → 1.4.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/CHANGELOG.md +6 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +4 -4
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +4 -4
- package/lib/benchmark/benches/recommended-oas3.bench.js +4 -4
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +3 -3
- package/lib/benchmark/utils.js +3 -3
- package/lib/bundle.d.ts +4 -4
- package/lib/bundle.js +23 -23
- package/lib/config/all.d.ts +2 -2
- package/lib/config/all.js +44 -8
- package/lib/config/builtIn.js +2 -0
- package/lib/config/config-resolvers.js +25 -25
- package/lib/config/config.js +9 -9
- package/lib/config/index.js +5 -1
- package/lib/config/load.d.ts +1 -1
- package/lib/config/load.js +6 -6
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/minimal.js +34 -3
- package/lib/config/recommended-strict.d.ts +3 -0
- package/lib/config/recommended-strict.js +92 -0
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.js +34 -3
- package/lib/config/rules.d.ts +1 -1
- package/lib/config/types.d.ts +47 -46
- package/lib/config/types.js +2 -2
- package/lib/config/utils.js +26 -14
- package/lib/decorators/common/filters/filter-helper.js +4 -4
- package/lib/decorators/common/filters/filter-in.js +2 -2
- package/lib/decorators/common/filters/filter-out.js +2 -2
- package/lib/decorators/common/info-description-override.js +1 -1
- package/lib/decorators/common/media-type-examples-override.js +3 -3
- package/lib/decorators/common/operation-description-override.js +1 -1
- package/lib/decorators/common/registry-dependencies.js +1 -1
- package/lib/decorators/common/remove-x-internal.js +4 -4
- package/lib/decorators/common/tag-description-override.js +1 -1
- package/lib/format/codeframes.d.ts +6 -6
- package/lib/format/format.d.ts +2 -2
- package/lib/format/format.js +12 -12
- package/lib/js-yaml/index.d.ts +2 -2
- package/lib/js-yaml/index.js +2 -2
- package/lib/lint.js +18 -18
- package/lib/oas-types.d.ts +12 -10
- package/lib/oas-types.js +2 -2
- package/lib/redocly/index.js +10 -10
- package/lib/redocly/registry-api.js +2 -2
- package/lib/resolve.d.ts +4 -4
- package/lib/resolve.js +18 -18
- package/lib/rules/ajv.js +1 -1
- package/lib/rules/async2/index.d.ts +2 -11
- package/lib/rules/common/assertions/asserts.d.ts +3 -3
- package/lib/rules/common/assertions/asserts.js +21 -21
- package/lib/rules/common/assertions/index.d.ts +4 -4
- package/lib/rules/common/assertions/index.js +3 -3
- package/lib/rules/common/assertions/utils.d.ts +4 -4
- package/lib/rules/common/assertions/utils.js +3 -3
- package/lib/rules/common/info-contact.js +1 -1
- package/lib/rules/common/info-license-url.js +1 -1
- package/lib/rules/common/info-license.js +1 -1
- package/lib/rules/common/no-enum-type-mismatch.js +3 -3
- package/lib/rules/common/no-http-verbs-in-paths.js +2 -2
- package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
- package/lib/rules/common/no-invalid-schema-examples.js +3 -3
- package/lib/rules/common/operation-2xx-response.js +2 -2
- package/lib/rules/common/operation-4xx-response.js +2 -2
- package/lib/rules/common/operation-description.js +1 -1
- package/lib/rules/common/operation-operationId.js +1 -1
- package/lib/rules/common/operation-summary.js +1 -1
- package/lib/rules/common/path-segment-plural.js +1 -1
- package/lib/rules/common/response-contains-header.js +2 -2
- package/lib/rules/common/spec-strict-refs.js +1 -1
- package/lib/rules/common/spec.js +11 -11
- package/lib/rules/common/tag-description.js +1 -1
- package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas2/index.d.ts +2 -46
- package/lib/rules/oas2/remove-unused-components.js +1 -1
- package/lib/rules/oas2/request-mime-type.js +2 -2
- package/lib/rules/oas2/response-contains-property.js +2 -2
- package/lib/rules/oas2/response-mime-type.js +2 -2
- package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas3/index.d.ts +1 -1
- package/lib/rules/oas3/index.js +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +3 -3
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +3 -3
- package/lib/rules/oas3/remove-unused-components.js +2 -2
- package/lib/rules/oas3/request-mime-type.js +3 -3
- package/lib/rules/oas3/response-contains-property.js +2 -2
- package/lib/rules/oas3/response-mime-type.js +3 -3
- package/lib/rules/utils.js +3 -3
- package/lib/types/asyncapi.js +21 -21
- package/lib/types/index.d.ts +8 -8
- package/lib/types/oas2.js +14 -14
- package/lib/types/oas3.js +27 -27
- package/lib/types/oas3_1.js +6 -6
- package/lib/types/redocly-yaml.d.ts +11 -0
- package/lib/types/redocly-yaml.js +71 -53
- package/lib/types/theme-config.js +1 -1
- package/lib/typings/common.d.ts +2 -2
- package/lib/typings/openapi.d.ts +6 -6
- package/lib/typings/swagger.d.ts +3 -3
- package/lib/utils.d.ts +5 -5
- package/lib/utils.js +3 -3
- package/lib/visitors.d.ts +40 -40
- package/lib/walk.d.ts +14 -15
- package/lib/walk.js +11 -11
- package/package.json +2 -2
- package/src/__tests__/lint.test.ts +40 -40
- package/src/__tests__/normalizeVisitors.test.ts +23 -5
- package/src/__tests__/ref-utils.test.ts +7 -7
- package/src/__tests__/resolve-http.test.ts +10 -10
- package/src/__tests__/resolve.test.ts +39 -39
- package/src/__tests__/walk.test.ts +48 -48
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +95 -32
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +81 -81
- package/src/config/__tests__/config-resolvers.test.ts +30 -1
- package/src/config/__tests__/config.test.ts +88 -88
- package/src/config/__tests__/load.test.ts +12 -8
- package/src/config/__tests__/utils.test.ts +18 -18
- package/src/config/all.ts +46 -9
- package/src/config/builtIn.ts +2 -0
- package/src/config/minimal.ts +36 -4
- package/src/config/recommended-strict.ts +93 -0
- package/src/config/recommended.ts +36 -4
- package/src/config/types.ts +22 -8
- package/src/config/utils.ts +15 -0
- package/src/decorators/common/media-type-examples-override.ts +2 -2
- package/src/lint.ts +3 -3
- package/src/oas-types.ts +26 -3
- package/src/rules/__tests__/no-unresolved-refs.test.ts +26 -26
- package/src/rules/async2/__tests__/channels-kebab-case.test.ts +12 -12
- package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +7 -7
- package/src/rules/async2/index.ts +2 -1
- package/src/rules/common/__tests__/info-license.test.ts +6 -6
- package/src/rules/common/__tests__/license-url.test.ts +6 -6
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +13 -13
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +18 -18
- package/src/rules/common/__tests__/no-identical-paths.test.ts +5 -5
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +12 -12
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +18 -18
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +23 -23
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +6 -6
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +5 -5
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +16 -16
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +6 -6
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +10 -10
- package/src/rules/common/__tests__/path-not-include-query.test.ts +6 -6
- package/src/rules/common/__tests__/path-params-defined.test.ts +21 -21
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +11 -11
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +18 -18
- package/src/rules/common/__tests__/security-defined.test.ts +21 -21
- package/src/rules/common/__tests__/spec-strict-refs.test.ts +9 -9
- package/src/rules/common/__tests__/spec.test.ts +102 -102
- package/src/rules/common/__tests__/tag-description.test.ts +6 -6
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +12 -12
- package/src/rules/common/assertions/__tests__/index.test.ts +15 -15
- package/src/rules/common/assertions/__tests__/utils.test.ts +9 -9
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -7
- package/src/rules/oas2/__tests__/response-contains-header.test.ts +13 -13
- package/src/rules/oas2/__tests__/response-contains-property.test.ts +8 -8
- package/src/rules/oas2/__tests__/spec/info.test.ts +21 -21
- package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
- package/src/rules/oas2/__tests__/spec/paths.test.ts +12 -12
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -1
- package/src/rules/oas2/index.ts +3 -1
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -7
- package/src/rules/oas3/__tests__/component-name-unique.test.ts +186 -186
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +18 -18
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +6 -6
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +36 -36
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +11 -11
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +7 -7
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +31 -31
- package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +15 -15
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +26 -26
- package/src/rules/oas3/__tests__/response-contains-property.test.ts +27 -27
- package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
- package/src/rules/oas3/__tests__/spec/info.test.ts +21 -21
- package/src/rules/oas3/__tests__/spec/operation.test.ts +10 -10
- package/src/rules/oas3/__tests__/spec/paths.test.ts +13 -13
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +2 -2
- package/src/rules/oas3/__tests__/spec/servers.test.ts +25 -25
- package/src/rules/oas3/__tests__/spec/spec.test.ts +56 -56
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +28 -28
- package/src/rules/oas3/index.ts +3 -3
- package/src/types/redocly-yaml.ts +75 -40
- package/src/visitors.ts +3 -3
- package/src/walk.ts +23 -10
- package/tsconfig.tsbuildinfo +1 -1
package/lib/config/types.d.ts
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import type { ProblemSeverity, UserContext } from '../walk';
|
|
2
|
-
import type { Oas3PreprocessorsSet, SpecMajorVersion, Oas3DecoratorsSet, Oas2RuleSet, Oas2PreprocessorsSet, Oas2DecoratorsSet, Oas3RuleSet, SpecVersion, Async2PreprocessorsSet, Async2DecoratorsSet, Async2RuleSet } from '../oas-types';
|
|
2
|
+
import type { Oas3PreprocessorsSet, SpecMajorVersion, Oas3DecoratorsSet, Oas2RuleSet, Oas2PreprocessorsSet, Oas2DecoratorsSet, Oas3RuleSet, SpecVersion, Async2PreprocessorsSet, Async2DecoratorsSet, Async2RuleSet, RuleMap } from '../oas-types';
|
|
3
3
|
import type { NodeType } from '../types';
|
|
4
4
|
import { Location } from '../ref-utils';
|
|
5
5
|
import type { SkipFunctionContext } from '../visitors';
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
import { BuiltInAsync2RuleId, BuiltInCommonOASRuleId, BuiltInCommonRuleId, BuiltInOAS2RuleId, BuiltInOAS3RuleId } from '../types/redocly-yaml';
|
|
7
|
+
export type RuleSeverity = ProblemSeverity | 'off';
|
|
8
|
+
export type RuleSettings = {
|
|
8
9
|
severity: RuleSeverity;
|
|
9
10
|
};
|
|
10
|
-
export
|
|
11
|
-
export
|
|
11
|
+
export type PreprocessorSeverity = RuleSeverity | 'on';
|
|
12
|
+
export type RuleConfig = RuleSeverity | ({
|
|
12
13
|
severity?: ProblemSeverity;
|
|
13
14
|
} & Record<string, any>);
|
|
14
|
-
export
|
|
15
|
+
export type PreprocessorConfig = PreprocessorSeverity | ({
|
|
15
16
|
severity?: ProblemSeverity;
|
|
16
17
|
} & Record<string, any>);
|
|
17
|
-
export
|
|
18
|
-
export
|
|
18
|
+
export type DecoratorConfig = PreprocessorConfig;
|
|
19
|
+
export type StyleguideRawConfig<T = undefined> = {
|
|
19
20
|
plugins?: (string | Plugin)[];
|
|
20
21
|
extends?: string[];
|
|
21
22
|
doNotResolveExamples?: boolean;
|
|
22
23
|
recommendedFallback?: boolean;
|
|
23
|
-
rules?:
|
|
24
|
-
oas2Rules?:
|
|
25
|
-
oas3_0Rules?:
|
|
26
|
-
oas3_1Rules?:
|
|
27
|
-
async2Rules?:
|
|
24
|
+
rules?: RuleMap<BuiltInCommonRuleId | BuiltInCommonOASRuleId, RuleConfig, T>;
|
|
25
|
+
oas2Rules?: RuleMap<BuiltInOAS2RuleId, RuleConfig, T>;
|
|
26
|
+
oas3_0Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
|
|
27
|
+
oas3_1Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
|
|
28
|
+
async2Rules?: RuleMap<BuiltInAsync2RuleId, RuleConfig, T>;
|
|
28
29
|
preprocessors?: Record<string, PreprocessorConfig>;
|
|
29
30
|
oas2Preprocessors?: Record<string, PreprocessorConfig>;
|
|
30
31
|
oas3_0Preprocessors?: Record<string, PreprocessorConfig>;
|
|
@@ -36,41 +37,41 @@ export declare type StyleguideRawConfig = {
|
|
|
36
37
|
oas3_1Decorators?: Record<string, DecoratorConfig>;
|
|
37
38
|
async2Decorators?: Record<string, DecoratorConfig>;
|
|
38
39
|
};
|
|
39
|
-
export
|
|
40
|
-
export
|
|
40
|
+
export type ApiStyleguideRawConfig = Omit<StyleguideRawConfig, 'plugins'>;
|
|
41
|
+
export type ResolvedStyleguideConfig = PluginStyleguideConfig & {
|
|
41
42
|
plugins?: Plugin[];
|
|
42
43
|
recommendedFallback?: boolean;
|
|
43
44
|
extends?: void | never;
|
|
44
45
|
extendPaths?: string[];
|
|
45
46
|
pluginPaths?: string[];
|
|
46
47
|
};
|
|
47
|
-
export
|
|
48
|
+
export type PreprocessorsConfig = {
|
|
48
49
|
oas3?: Oas3PreprocessorsSet;
|
|
49
50
|
oas2?: Oas2PreprocessorsSet;
|
|
50
51
|
async2?: Async2PreprocessorsSet;
|
|
51
52
|
};
|
|
52
|
-
export
|
|
53
|
+
export type DecoratorsConfig = {
|
|
53
54
|
oas3?: Oas3DecoratorsSet;
|
|
54
55
|
oas2?: Oas2DecoratorsSet;
|
|
55
56
|
async2?: Async2DecoratorsSet;
|
|
56
57
|
};
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
58
|
+
export type TypesExtensionFn = (types: Record<string, NodeType>, oasVersion: SpecVersion) => Record<string, NodeType>;
|
|
59
|
+
export type TypeExtensionsConfig = Partial<Record<SpecMajorVersion, TypesExtensionFn>>;
|
|
60
|
+
export type CustomRulesConfig = {
|
|
60
61
|
oas3?: Oas3RuleSet;
|
|
61
62
|
oas2?: Oas2RuleSet;
|
|
62
63
|
async2?: Async2RuleSet;
|
|
63
64
|
};
|
|
64
|
-
export
|
|
65
|
+
export type AssertionContext = Partial<UserContext> & SkipFunctionContext & {
|
|
65
66
|
node: any;
|
|
66
67
|
};
|
|
67
|
-
export
|
|
68
|
+
export type AssertResult = {
|
|
68
69
|
message?: string;
|
|
69
70
|
location?: Location;
|
|
70
71
|
};
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
72
|
+
export type CustomFunction = (value: any, options: unknown, baseLocation: Location) => AssertResult[];
|
|
73
|
+
export type AssertionsConfig = Record<string, CustomFunction>;
|
|
74
|
+
export type Plugin = {
|
|
74
75
|
id: string;
|
|
75
76
|
configs?: Record<string, PluginStyleguideConfig>;
|
|
76
77
|
rules?: CustomRulesConfig;
|
|
@@ -79,8 +80,8 @@ export declare type Plugin = {
|
|
|
79
80
|
typeExtension?: TypeExtensionsConfig;
|
|
80
81
|
assertions?: AssertionsConfig;
|
|
81
82
|
};
|
|
82
|
-
export
|
|
83
|
-
export
|
|
83
|
+
export type PluginStyleguideConfig<T = undefined> = Omit<StyleguideRawConfig<T>, 'plugins' | 'extends'>;
|
|
84
|
+
export type ResolveHeader = {
|
|
84
85
|
name: string;
|
|
85
86
|
envVariable?: undefined;
|
|
86
87
|
value: string;
|
|
@@ -91,41 +92,41 @@ export declare type ResolveHeader = {
|
|
|
91
92
|
envVariable: string;
|
|
92
93
|
matches: string;
|
|
93
94
|
};
|
|
94
|
-
export
|
|
95
|
+
export type RawResolveConfig = {
|
|
95
96
|
http?: Partial<HttpResolveConfig>;
|
|
96
97
|
doNotResolveExamples?: boolean;
|
|
97
98
|
};
|
|
98
|
-
export
|
|
99
|
+
export type HttpResolveConfig = {
|
|
99
100
|
headers: ResolveHeader[];
|
|
100
101
|
customFetch?: Function;
|
|
101
102
|
};
|
|
102
|
-
export
|
|
103
|
+
export type ResolveConfig = {
|
|
103
104
|
http: HttpResolveConfig;
|
|
104
105
|
};
|
|
105
|
-
export
|
|
106
|
-
export
|
|
107
|
-
export
|
|
106
|
+
export type Region = 'us' | 'eu';
|
|
107
|
+
export type Telemetry = 'on' | 'off';
|
|
108
|
+
export type AccessTokens = {
|
|
108
109
|
[region in Region]?: string;
|
|
109
110
|
};
|
|
110
|
-
export
|
|
111
|
+
export type DeprecatedInRawConfig = {
|
|
111
112
|
apiDefinitions?: Record<string, string>;
|
|
112
113
|
lint?: StyleguideRawConfig;
|
|
113
114
|
styleguide?: StyleguideRawConfig;
|
|
114
115
|
referenceDocs?: Record<string, any>;
|
|
115
116
|
apis?: Record<string, Api & DeprecatedInApi>;
|
|
116
117
|
} & DeprecatedFeaturesConfig;
|
|
117
|
-
export
|
|
118
|
+
export type Api = {
|
|
118
119
|
root: string;
|
|
119
120
|
styleguide?: ApiStyleguideRawConfig;
|
|
120
121
|
} & ThemeConfig;
|
|
121
|
-
export
|
|
122
|
+
export type DeprecatedInApi = {
|
|
122
123
|
lint?: ApiStyleguideRawConfig;
|
|
123
124
|
} & DeprecatedFeaturesConfig;
|
|
124
|
-
export
|
|
125
|
+
export type ResolvedApi = Omit<Api, 'styleguide'> & {
|
|
125
126
|
styleguide: ResolvedStyleguideConfig;
|
|
126
127
|
files?: string[];
|
|
127
128
|
};
|
|
128
|
-
export
|
|
129
|
+
export type RawConfig = {
|
|
129
130
|
apis?: Record<string, Api>;
|
|
130
131
|
styleguide?: StyleguideRawConfig;
|
|
131
132
|
resolve?: RawResolveConfig;
|
|
@@ -134,28 +135,28 @@ export declare type RawConfig = {
|
|
|
134
135
|
files?: string[];
|
|
135
136
|
telemetry?: Telemetry;
|
|
136
137
|
} & ThemeConfig;
|
|
137
|
-
export
|
|
138
|
-
export
|
|
139
|
-
export
|
|
138
|
+
export type RawUniversalConfig = Omit<RawConfig, 'styleguide'> & StyleguideRawConfig;
|
|
139
|
+
export type FlatApi = Omit<Api, 'styleguide'> & Omit<ApiStyleguideRawConfig, 'doNotResolveExamples'>;
|
|
140
|
+
export type FlatRawConfig = Omit<RawConfig, 'styleguide' | 'resolve' | 'apis'> & Omit<StyleguideRawConfig, 'doNotResolveExamples'> & {
|
|
140
141
|
resolve?: RawResolveConfig;
|
|
141
142
|
apis?: Record<string, FlatApi>;
|
|
142
143
|
} & ThemeRawConfig;
|
|
143
|
-
export
|
|
144
|
+
export type ResolvedConfig = Omit<RawConfig, 'apis' | 'styleguide'> & {
|
|
144
145
|
apis: Record<string, ResolvedApi>;
|
|
145
146
|
styleguide: ResolvedStyleguideConfig;
|
|
146
147
|
};
|
|
147
|
-
|
|
148
|
+
type DeprecatedFeaturesConfig = {
|
|
148
149
|
'features.openapi'?: Record<string, any>;
|
|
149
150
|
'features.mockServer'?: Record<string, any>;
|
|
150
151
|
};
|
|
151
|
-
export
|
|
152
|
+
export type ThemeConfig = {
|
|
152
153
|
theme?: ThemeRawConfig;
|
|
153
154
|
};
|
|
154
|
-
export
|
|
155
|
+
export type ThemeRawConfig = {
|
|
155
156
|
openapi?: Record<string, any>;
|
|
156
157
|
mockServer?: Record<string, any>;
|
|
157
158
|
};
|
|
158
|
-
export
|
|
159
|
+
export type RulesFields = 'rules' | 'oas2Rules' | 'oas3_0Rules' | 'oas3_1Rules' | 'async2Rules' | 'preprocessors' | 'oas2Preprocessors' | 'oas3_0Preprocessors' | 'oas3_1Preprocessors' | 'async2Preprocessors' | 'decorators' | 'oas2Decorators' | 'oas3_0Decorators' | 'oas3_1Decorators' | 'async2Decorators';
|
|
159
160
|
export declare enum AuthProviderType {
|
|
160
161
|
OIDC = "OIDC",
|
|
161
162
|
SAML2 = "SAML2",
|
package/lib/config/types.js
CHANGED
|
@@ -6,10 +6,10 @@ var AuthProviderType;
|
|
|
6
6
|
AuthProviderType["OIDC"] = "OIDC";
|
|
7
7
|
AuthProviderType["SAML2"] = "SAML2";
|
|
8
8
|
AuthProviderType["BASIC"] = "BASIC";
|
|
9
|
-
})(AuthProviderType
|
|
9
|
+
})(AuthProviderType || (exports.AuthProviderType = AuthProviderType = {}));
|
|
10
10
|
var ApigeeDevOnboardingIntegrationAuthType;
|
|
11
11
|
(function (ApigeeDevOnboardingIntegrationAuthType) {
|
|
12
12
|
ApigeeDevOnboardingIntegrationAuthType["SERVICE_ACCOUNT"] = "SERVICE_ACCOUNT";
|
|
13
13
|
ApigeeDevOnboardingIntegrationAuthType["OAUTH2"] = "OAUTH2";
|
|
14
|
-
})(ApigeeDevOnboardingIntegrationAuthType
|
|
14
|
+
})(ApigeeDevOnboardingIntegrationAuthType || (exports.ApigeeDevOnboardingIntegrationAuthType = ApigeeDevOnboardingIntegrationAuthType = {}));
|
|
15
15
|
exports.DEFAULT_TEAM_CLAIM_NAME = 'https://redocly.com/sso/teams';
|
package/lib/config/utils.js
CHANGED
|
@@ -37,7 +37,7 @@ function transformApiDefinitionsToApis(apiDefinitions) {
|
|
|
37
37
|
exports.transformApiDefinitionsToApis = transformApiDefinitionsToApis;
|
|
38
38
|
function extractFlatConfig(_a) {
|
|
39
39
|
var _b;
|
|
40
|
-
var { plugins, extends: _extends, rules, oas2Rules, oas3_0Rules, oas3_1Rules, preprocessors, oas2Preprocessors, oas3_0Preprocessors, oas3_1Preprocessors, decorators, oas2Decorators, oas3_0Decorators, oas3_1Decorators } = _a, rawConfigRest = __rest(_a, ["plugins", "extends", "rules", "oas2Rules", "oas3_0Rules", "oas3_1Rules", "preprocessors", "oas2Preprocessors", "oas3_0Preprocessors", "oas3_1Preprocessors", "decorators", "oas2Decorators", "oas3_0Decorators", "oas3_1Decorators"]);
|
|
40
|
+
var { plugins, extends: _extends, rules, oas2Rules, oas3_0Rules, oas3_1Rules, async2Rules, preprocessors, oas2Preprocessors, oas3_0Preprocessors, oas3_1Preprocessors, async2Preprocessors, decorators, oas2Decorators, oas3_0Decorators, oas3_1Decorators, async2Decorators } = _a, rawConfigRest = __rest(_a, ["plugins", "extends", "rules", "oas2Rules", "oas3_0Rules", "oas3_1Rules", "async2Rules", "preprocessors", "oas2Preprocessors", "oas3_0Preprocessors", "oas3_1Preprocessors", "async2Preprocessors", "decorators", "oas2Decorators", "oas3_0Decorators", "oas3_1Decorators", "async2Decorators"]);
|
|
41
41
|
const styleguideConfig = {
|
|
42
42
|
plugins,
|
|
43
43
|
extends: _extends,
|
|
@@ -45,14 +45,17 @@ function extractFlatConfig(_a) {
|
|
|
45
45
|
oas2Rules,
|
|
46
46
|
oas3_0Rules,
|
|
47
47
|
oas3_1Rules,
|
|
48
|
+
async2Rules,
|
|
48
49
|
preprocessors,
|
|
49
50
|
oas2Preprocessors,
|
|
50
51
|
oas3_0Preprocessors,
|
|
51
52
|
oas3_1Preprocessors,
|
|
53
|
+
async2Preprocessors,
|
|
52
54
|
decorators,
|
|
53
55
|
oas2Decorators,
|
|
54
56
|
oas3_0Decorators,
|
|
55
57
|
oas3_1Decorators,
|
|
58
|
+
async2Decorators,
|
|
56
59
|
doNotResolveExamples: (_b = rawConfigRest.resolve) === null || _b === void 0 ? void 0 : _b.doNotResolveExamples,
|
|
57
60
|
};
|
|
58
61
|
if ((rawConfigRest.lint && rawConfigRest.styleguide) ||
|
|
@@ -94,14 +97,17 @@ function mergeExtends(rulesConfList) {
|
|
|
94
97
|
oas2Rules: {},
|
|
95
98
|
oas3_0Rules: {},
|
|
96
99
|
oas3_1Rules: {},
|
|
100
|
+
async2Rules: {},
|
|
97
101
|
preprocessors: {},
|
|
98
102
|
oas2Preprocessors: {},
|
|
99
103
|
oas3_0Preprocessors: {},
|
|
100
104
|
oas3_1Preprocessors: {},
|
|
105
|
+
async2Preprocessors: {},
|
|
101
106
|
decorators: {},
|
|
102
107
|
oas2Decorators: {},
|
|
103
108
|
oas3_0Decorators: {},
|
|
104
109
|
oas3_1Decorators: {},
|
|
110
|
+
async2Decorators: {},
|
|
105
111
|
plugins: [],
|
|
106
112
|
pluginPaths: [],
|
|
107
113
|
extendPaths: [],
|
|
@@ -112,25 +118,31 @@ function mergeExtends(rulesConfList) {
|
|
|
112
118
|
}
|
|
113
119
|
Object.assign(result.rules, rulesConf.rules);
|
|
114
120
|
Object.assign(result.oas2Rules, rulesConf.oas2Rules);
|
|
115
|
-
utils_1.assignExisting(result.oas2Rules, rulesConf.rules || {});
|
|
121
|
+
(0, utils_1.assignExisting)(result.oas2Rules, rulesConf.rules || {});
|
|
116
122
|
Object.assign(result.oas3_0Rules, rulesConf.oas3_0Rules);
|
|
117
|
-
utils_1.assignExisting(result.oas3_0Rules, rulesConf.rules || {});
|
|
123
|
+
(0, utils_1.assignExisting)(result.oas3_0Rules, rulesConf.rules || {});
|
|
118
124
|
Object.assign(result.oas3_1Rules, rulesConf.oas3_1Rules);
|
|
119
|
-
utils_1.assignExisting(result.oas3_1Rules, rulesConf.rules || {});
|
|
125
|
+
(0, utils_1.assignExisting)(result.oas3_1Rules, rulesConf.rules || {});
|
|
126
|
+
Object.assign(result.async2Rules, rulesConf.async2Rules);
|
|
127
|
+
(0, utils_1.assignExisting)(result.async2Rules, rulesConf.rules || {});
|
|
120
128
|
Object.assign(result.preprocessors, rulesConf.preprocessors);
|
|
121
129
|
Object.assign(result.oas2Preprocessors, rulesConf.oas2Preprocessors);
|
|
122
|
-
utils_1.assignExisting(result.oas2Preprocessors, rulesConf.preprocessors || {});
|
|
130
|
+
(0, utils_1.assignExisting)(result.oas2Preprocessors, rulesConf.preprocessors || {});
|
|
123
131
|
Object.assign(result.oas3_0Preprocessors, rulesConf.oas3_0Preprocessors);
|
|
124
|
-
utils_1.assignExisting(result.oas3_0Preprocessors, rulesConf.preprocessors || {});
|
|
132
|
+
(0, utils_1.assignExisting)(result.oas3_0Preprocessors, rulesConf.preprocessors || {});
|
|
125
133
|
Object.assign(result.oas3_1Preprocessors, rulesConf.oas3_1Preprocessors);
|
|
126
|
-
utils_1.assignExisting(result.oas3_1Preprocessors, rulesConf.preprocessors || {});
|
|
134
|
+
(0, utils_1.assignExisting)(result.oas3_1Preprocessors, rulesConf.preprocessors || {});
|
|
135
|
+
Object.assign(result.async2Preprocessors, rulesConf.async2Preprocessors);
|
|
136
|
+
(0, utils_1.assignExisting)(result.async2Preprocessors, rulesConf.preprocessors || {});
|
|
127
137
|
Object.assign(result.decorators, rulesConf.decorators);
|
|
128
138
|
Object.assign(result.oas2Decorators, rulesConf.oas2Decorators);
|
|
129
|
-
utils_1.assignExisting(result.oas2Decorators, rulesConf.decorators || {});
|
|
139
|
+
(0, utils_1.assignExisting)(result.oas2Decorators, rulesConf.decorators || {});
|
|
130
140
|
Object.assign(result.oas3_0Decorators, rulesConf.oas3_0Decorators);
|
|
131
|
-
utils_1.assignExisting(result.oas3_0Decorators, rulesConf.decorators || {});
|
|
141
|
+
(0, utils_1.assignExisting)(result.oas3_0Decorators, rulesConf.decorators || {});
|
|
132
142
|
Object.assign(result.oas3_1Decorators, rulesConf.oas3_1Decorators);
|
|
133
|
-
utils_1.assignExisting(result.oas3_1Decorators, rulesConf.decorators || {});
|
|
143
|
+
(0, utils_1.assignExisting)(result.oas3_1Decorators, rulesConf.decorators || {});
|
|
144
|
+
Object.assign(result.async2Decorators, rulesConf.async2Decorators);
|
|
145
|
+
(0, utils_1.assignExisting)(result.async2Decorators, rulesConf.decorators || {});
|
|
134
146
|
result.plugins.push(...(rulesConf.plugins || []));
|
|
135
147
|
result.pluginPaths.push(...(rulesConf.pluginPaths || []));
|
|
136
148
|
result.extendPaths.push(...new Set(rulesConf.extendPaths));
|
|
@@ -164,16 +176,16 @@ function checkForDeprecatedFields(deprecatedField, updatedField, rawConfig, upda
|
|
|
164
176
|
const isDeprecatedFieldInApis = rawConfig.apis &&
|
|
165
177
|
Object.values(rawConfig.apis).some((api) => api[deprecatedField]);
|
|
166
178
|
if (rawConfig[deprecatedField] && updatedField === null) {
|
|
167
|
-
utils_1.showWarningForDeprecatedField(deprecatedField);
|
|
179
|
+
(0, utils_1.showWarningForDeprecatedField)(deprecatedField);
|
|
168
180
|
}
|
|
169
181
|
if (rawConfig[deprecatedField] && updatedField && rawConfig[updatedField]) {
|
|
170
|
-
utils_1.showErrorForDeprecatedField(deprecatedField, updatedField);
|
|
182
|
+
(0, utils_1.showErrorForDeprecatedField)(deprecatedField, updatedField);
|
|
171
183
|
}
|
|
172
184
|
if (rawConfig[deprecatedField] && updatedObject && rawConfig[updatedObject]) {
|
|
173
|
-
utils_1.showErrorForDeprecatedField(deprecatedField, updatedField, updatedObject);
|
|
185
|
+
(0, utils_1.showErrorForDeprecatedField)(deprecatedField, updatedField, updatedObject);
|
|
174
186
|
}
|
|
175
187
|
if (rawConfig[deprecatedField] || isDeprecatedFieldInApis) {
|
|
176
|
-
utils_1.showWarningForDeprecatedField(deprecatedField, updatedField, updatedObject);
|
|
188
|
+
(0, utils_1.showWarningForDeprecatedField)(deprecatedField, updatedField, updatedObject);
|
|
177
189
|
}
|
|
178
190
|
}
|
|
179
191
|
exports.checkForDeprecatedFields = checkForDeprecatedFields;
|
|
@@ -8,7 +8,7 @@ function filter(node, ctx, criteria) {
|
|
|
8
8
|
let didDelete = false;
|
|
9
9
|
if (Array.isArray(node)) {
|
|
10
10
|
for (let i = 0; i < node.length; i++) {
|
|
11
|
-
if (ref_utils_1.isRef(node[i])) {
|
|
11
|
+
if ((0, ref_utils_1.isRef)(node[i])) {
|
|
12
12
|
const resolved = ctx.resolve(node[i]);
|
|
13
13
|
if (criteria(resolved.node)) {
|
|
14
14
|
node.splice(i, 1);
|
|
@@ -23,10 +23,10 @@ function filter(node, ctx, criteria) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
else if (utils_1.isPlainObject(node)) {
|
|
26
|
+
else if ((0, utils_1.isPlainObject)(node)) {
|
|
27
27
|
for (const key of Object.keys(node)) {
|
|
28
28
|
node = node;
|
|
29
|
-
if (ref_utils_1.isRef(node[key])) {
|
|
29
|
+
if ((0, ref_utils_1.isRef)(node[key])) {
|
|
30
30
|
const resolved = ctx.resolve(node[key]);
|
|
31
31
|
if (criteria(resolved.node)) {
|
|
32
32
|
delete node[key];
|
|
@@ -39,7 +39,7 @@ function filter(node, ctx, criteria) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
if (didDelete && (utils_1.isEmptyObject(node) || utils_1.isEmptyArray(node))) {
|
|
42
|
+
if (didDelete && ((0, utils_1.isEmptyObject)(node) || (0, utils_1.isEmptyArray)(node))) {
|
|
43
43
|
delete parent[key];
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -5,11 +5,11 @@ const filter_helper_1 = require("./filter-helper");
|
|
|
5
5
|
const DEFAULT_STRATEGY = 'any';
|
|
6
6
|
const FilterIn = ({ property, value, matchStrategy }) => {
|
|
7
7
|
const strategy = matchStrategy || DEFAULT_STRATEGY;
|
|
8
|
-
const filterInCriteria = (item) => (item === null || item === void 0 ? void 0 : item[property]) && !filter_helper_1.checkIfMatchByStrategy(item === null || item === void 0 ? void 0 : item[property], value, strategy);
|
|
8
|
+
const filterInCriteria = (item) => (item === null || item === void 0 ? void 0 : item[property]) && !(0, filter_helper_1.checkIfMatchByStrategy)(item === null || item === void 0 ? void 0 : item[property], value, strategy);
|
|
9
9
|
return {
|
|
10
10
|
any: {
|
|
11
11
|
enter: (node, ctx) => {
|
|
12
|
-
filter_helper_1.filter(node, ctx, filterInCriteria);
|
|
12
|
+
(0, filter_helper_1.filter)(node, ctx, filterInCriteria);
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
};
|
|
@@ -5,11 +5,11 @@ const filter_helper_1 = require("./filter-helper");
|
|
|
5
5
|
const DEFAULT_STRATEGY = 'any';
|
|
6
6
|
const FilterOut = ({ property, value, matchStrategy }) => {
|
|
7
7
|
const strategy = matchStrategy || DEFAULT_STRATEGY;
|
|
8
|
-
const filterOutCriteria = (item) => filter_helper_1.checkIfMatchByStrategy(item === null || item === void 0 ? void 0 : item[property], value, strategy);
|
|
8
|
+
const filterOutCriteria = (item) => (0, filter_helper_1.checkIfMatchByStrategy)(item === null || item === void 0 ? void 0 : item[property], value, strategy);
|
|
9
9
|
return {
|
|
10
10
|
any: {
|
|
11
11
|
enter: (node, ctx) => {
|
|
12
|
-
filter_helper_1.filter(node, ctx, filterOutCriteria);
|
|
12
|
+
(0, filter_helper_1.filter)(node, ctx, filterOutCriteria);
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
};
|
|
@@ -9,7 +9,7 @@ const InfoDescriptionOverride = ({ filePath }) => {
|
|
|
9
9
|
if (!filePath)
|
|
10
10
|
throw new Error(`Parameter "filePath" is not provided for "info-description-override" rule`);
|
|
11
11
|
try {
|
|
12
|
-
info.description = utils_1.readFileAsStringSync(filePath);
|
|
12
|
+
info.description = (0, utils_1.readFileAsStringSync)(filePath);
|
|
13
13
|
}
|
|
14
14
|
catch (e) {
|
|
15
15
|
report({
|
|
@@ -23,7 +23,7 @@ const MediaTypeExamplesOverride = ({ operationIds }) => {
|
|
|
23
23
|
}
|
|
24
24
|
resolvedResponse.content = resolvedResponse.content ? resolvedResponse.content : {};
|
|
25
25
|
Object.keys(properties.responses[responseCode]).forEach((mimeType) => {
|
|
26
|
-
resolvedResponse.content[mimeType] = Object.assign(Object.assign({}, resolvedResponse.content[mimeType]), { examples: utils_1.yamlAndJsonSyncReader(properties.responses[responseCode][mimeType]) });
|
|
26
|
+
resolvedResponse.content[mimeType] = Object.assign(Object.assign({}, resolvedResponse.content[mimeType]), { examples: (0, utils_1.yamlAndJsonSyncReader)(properties.responses[responseCode][mimeType]) });
|
|
27
27
|
});
|
|
28
28
|
operation.responses[responseCode] = resolvedResponse;
|
|
29
29
|
}
|
|
@@ -35,7 +35,7 @@ const MediaTypeExamplesOverride = ({ operationIds }) => {
|
|
|
35
35
|
}
|
|
36
36
|
resolvedRequest.content = resolvedRequest.content ? resolvedRequest.content : {};
|
|
37
37
|
Object.keys(properties.request).forEach((mimeType) => {
|
|
38
|
-
resolvedRequest.content[mimeType] = Object.assign(Object.assign({}, resolvedRequest.content[mimeType]), { examples: utils_1.yamlAndJsonSyncReader(properties.request[mimeType]) });
|
|
38
|
+
resolvedRequest.content[mimeType] = Object.assign(Object.assign({}, resolvedRequest.content[mimeType]), { examples: (0, utils_1.yamlAndJsonSyncReader)(properties.request[mimeType]) });
|
|
39
39
|
});
|
|
40
40
|
operation.requestBody = resolvedRequest;
|
|
41
41
|
}
|
|
@@ -45,7 +45,7 @@ const MediaTypeExamplesOverride = ({ operationIds }) => {
|
|
|
45
45
|
};
|
|
46
46
|
exports.MediaTypeExamplesOverride = MediaTypeExamplesOverride;
|
|
47
47
|
function checkAndResolveRef(node, resolver) {
|
|
48
|
-
if (!ref_utils_1.isRef(node)) {
|
|
48
|
+
if (!(0, ref_utils_1.isRef)(node)) {
|
|
49
49
|
return node;
|
|
50
50
|
}
|
|
51
51
|
const resolved = resolver(node);
|
|
@@ -13,7 +13,7 @@ const OperationDescriptionOverride = ({ operationIds }) => {
|
|
|
13
13
|
const operationId = operation.operationId;
|
|
14
14
|
if (operationIds[operationId]) {
|
|
15
15
|
try {
|
|
16
|
-
operation.description = utils_1.readFileAsStringSync(operationIds[operationId]);
|
|
16
|
+
operation.description = (0, utils_1.readFileAsStringSync)(operationIds[operationId]);
|
|
17
17
|
}
|
|
18
18
|
catch (e) {
|
|
19
19
|
report({
|
|
@@ -12,7 +12,7 @@ const RemoveXInternal = ({ internalFlagProperty }) => {
|
|
|
12
12
|
let didDelete = false;
|
|
13
13
|
if (Array.isArray(node)) {
|
|
14
14
|
for (let i = 0; i < node.length; i++) {
|
|
15
|
-
if (ref_utils_1.isRef(node[i])) {
|
|
15
|
+
if ((0, ref_utils_1.isRef)(node[i])) {
|
|
16
16
|
const resolved = ctx.resolve(node[i]);
|
|
17
17
|
if ((_a = resolved.node) === null || _a === void 0 ? void 0 : _a[hiddenTag]) {
|
|
18
18
|
node.splice(i, 1);
|
|
@@ -27,10 +27,10 @@ const RemoveXInternal = ({ internalFlagProperty }) => {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
else if (utils_1.isPlainObject(node)) {
|
|
30
|
+
else if ((0, utils_1.isPlainObject)(node)) {
|
|
31
31
|
for (const key of Object.keys(node)) {
|
|
32
32
|
node = node;
|
|
33
|
-
if (ref_utils_1.isRef(node[key])) {
|
|
33
|
+
if ((0, ref_utils_1.isRef)(node[key])) {
|
|
34
34
|
const resolved = ctx.resolve(node[key]);
|
|
35
35
|
if ((_c = resolved.node) === null || _c === void 0 ? void 0 : _c[hiddenTag]) {
|
|
36
36
|
delete node[key];
|
|
@@ -43,7 +43,7 @@ const RemoveXInternal = ({ internalFlagProperty }) => {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
if (didDelete && (utils_1.isEmptyObject(node) || utils_1.isEmptyArray(node))) {
|
|
46
|
+
if (didDelete && ((0, utils_1.isEmptyObject)(node) || (0, utils_1.isEmptyArray)(node))) {
|
|
47
47
|
delete parent[key];
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -10,7 +10,7 @@ const TagDescriptionOverride = ({ tagNames }) => {
|
|
|
10
10
|
throw new Error(`Parameter "tagNames" is not provided for "tag-description-override" rule`);
|
|
11
11
|
if (tagNames[tag.name]) {
|
|
12
12
|
try {
|
|
13
|
-
tag.description = utils_1.readFileAsStringSync(tagNames[tag.name]);
|
|
13
|
+
tag.description = (0, utils_1.readFileAsStringSync)(tagNames[tag.name]);
|
|
14
14
|
}
|
|
15
15
|
catch (e) {
|
|
16
16
|
report({
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import * as yamlAst from 'yaml-ast-parser';
|
|
2
2
|
import { LineColLocationObject, LocationObject } from '../walk';
|
|
3
|
-
|
|
3
|
+
type YAMLMapping = yamlAst.YAMLMapping & {
|
|
4
4
|
kind: yamlAst.Kind.MAPPING;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
type YAMLMap = yamlAst.YamlMap & {
|
|
7
7
|
kind: yamlAst.Kind.MAP;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type YAMLAnchorReference = yamlAst.YAMLAnchorReference & {
|
|
10
10
|
kind: yamlAst.Kind.ANCHOR_REF;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type YAMLSequence = yamlAst.YAMLSequence & {
|
|
13
13
|
kind: yamlAst.Kind.SEQ;
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
type YAMLScalar = yamlAst.YAMLScalar & {
|
|
16
16
|
kind: yamlAst.Kind.SCALAR;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
type YAMLNode = YAMLMapping | YAMLMap | YAMLAnchorReference | YAMLSequence | YAMLScalar;
|
|
19
19
|
export declare function getCodeframe(location: LineColLocationObject, color: boolean): string;
|
|
20
20
|
export declare function getLineColLocation(location: LocationObject): LineColLocationObject;
|
|
21
21
|
export declare function getAstNodeByPointer(root: YAMLNode, pointer: string, reportOnKey: boolean): YAMLMapping | YAMLMap | YAMLAnchorReference | YAMLSequence | yamlAst.YAMLScalar | undefined;
|
package/lib/format/format.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NormalizedProblem } from '../walk';
|
|
2
|
-
export
|
|
2
|
+
export type Totals = {
|
|
3
3
|
errors: number;
|
|
4
4
|
warnings: number;
|
|
5
5
|
ignored: number;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type OutputFormat = 'codeframe' | 'stylish' | 'json' | 'checkstyle' | 'codeclimate' | 'summary';
|
|
8
8
|
export declare function getTotals(problems: (NormalizedProblem & {
|
|
9
9
|
ignored?: boolean;
|
|
10
10
|
})[]): Totals;
|
package/lib/format/format.js
CHANGED
|
@@ -76,7 +76,7 @@ function formatProblems(problems, opts) {
|
|
|
76
76
|
case 'stylish': {
|
|
77
77
|
const groupedByFile = groupByFiles(problems);
|
|
78
78
|
for (const [file, { ruleIdPad, locationPad: positionPad, fileProblems }] of Object.entries(groupedByFile)) {
|
|
79
|
-
logger_1.logger.info(`${logger_1.colorize.blue(ref_utils_1.isAbsoluteUrl(file) ? file : path.relative(cwd, file))}:\n`);
|
|
79
|
+
logger_1.logger.info(`${logger_1.colorize.blue((0, ref_utils_1.isAbsoluteUrl)(file) ? file : path.relative(cwd, file))}:\n`);
|
|
80
80
|
for (let i = 0; i < fileProblems.length; i++) {
|
|
81
81
|
const problem = fileProblems[i];
|
|
82
82
|
logger_1.logger.info(`${formatStylish(problem, positionPad, ruleIdPad)}\n`);
|
|
@@ -90,7 +90,7 @@ function formatProblems(problems, opts) {
|
|
|
90
90
|
output_1.output.write('<?xml version="1.0" encoding="UTF-8"?>\n');
|
|
91
91
|
output_1.output.write('<checkstyle version="4.3">\n');
|
|
92
92
|
for (const [file, { fileProblems }] of Object.entries(groupedByFile)) {
|
|
93
|
-
output_1.output.write(`<file name="${xmlEscape(ref_utils_1.isAbsoluteUrl(file) ? file : path.relative(cwd, file))}">\n`);
|
|
93
|
+
output_1.output.write(`<file name="${xmlEscape((0, ref_utils_1.isAbsoluteUrl)(file) ? file : path.relative(cwd, file))}">\n`);
|
|
94
94
|
fileProblems.forEach(formatCheckstyle);
|
|
95
95
|
output_1.output.write(`</file>\n`);
|
|
96
96
|
}
|
|
@@ -110,11 +110,11 @@ function formatProblems(problems, opts) {
|
|
|
110
110
|
function outputForCodeClimate() {
|
|
111
111
|
const issues = problems.map((p) => {
|
|
112
112
|
const location = p.location[0]; // TODO: support multiple location
|
|
113
|
-
const lineCol = codeframes_1.getLineColLocation(location);
|
|
113
|
+
const lineCol = (0, codeframes_1.getLineColLocation)(location);
|
|
114
114
|
return {
|
|
115
115
|
description: p.message,
|
|
116
116
|
location: {
|
|
117
|
-
path: ref_utils_1.isAbsoluteUrl(location.source.absoluteRef)
|
|
117
|
+
path: (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef)
|
|
118
118
|
? location.source.absoluteRef
|
|
119
119
|
: path.relative(cwd, location.source.absoluteRef),
|
|
120
120
|
lines: {
|
|
@@ -134,19 +134,19 @@ function formatProblems(problems, opts) {
|
|
|
134
134
|
problems: problems.map((p) => {
|
|
135
135
|
var _a, _b, _c;
|
|
136
136
|
const problem = Object.assign(Object.assign({}, p), { location: p.location.map((location) => (Object.assign(Object.assign({}, location), { source: {
|
|
137
|
-
ref: ref_utils_1.isAbsoluteUrl(location.source.absoluteRef)
|
|
137
|
+
ref: (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef)
|
|
138
138
|
? location.source.absoluteRef
|
|
139
139
|
: path.relative(cwd, location.source.absoluteRef),
|
|
140
140
|
} }))), from: p.from
|
|
141
141
|
? Object.assign(Object.assign({}, p.from), { source: {
|
|
142
|
-
ref: ref_utils_1.isAbsoluteUrl((_a = p.from) === null || _a === void 0 ? void 0 : _a.source.absoluteRef)
|
|
142
|
+
ref: (0, ref_utils_1.isAbsoluteUrl)((_a = p.from) === null || _a === void 0 ? void 0 : _a.source.absoluteRef)
|
|
143
143
|
? (_b = p.from) === null || _b === void 0 ? void 0 : _b.source.absoluteRef
|
|
144
144
|
: path.relative(cwd, ((_c = p.from) === null || _c === void 0 ? void 0 : _c.source.absoluteRef) || cwd),
|
|
145
145
|
} }) : undefined });
|
|
146
146
|
if (env_1.env.FORMAT_JSON_WITH_CODEFRAMES) {
|
|
147
147
|
const location = p.location[0]; // TODO: support multiple locations
|
|
148
|
-
const loc = codeframes_1.getLineColLocation(location);
|
|
149
|
-
problem.codeframe = codeframes_1.getCodeframe(loc, color);
|
|
148
|
+
const loc = (0, codeframes_1.getLineColLocation)(location);
|
|
149
|
+
problem.codeframe = (0, codeframes_1.getCodeframe)(loc, color);
|
|
150
150
|
}
|
|
151
151
|
return problem;
|
|
152
152
|
}),
|
|
@@ -163,16 +163,16 @@ function formatProblems(problems, opts) {
|
|
|
163
163
|
function formatCodeframe(problem, idx) {
|
|
164
164
|
const bgColor = getBgColor(problem);
|
|
165
165
|
const location = problem.location[0]; // TODO: support multiple locations
|
|
166
|
-
const relativePath = ref_utils_1.isAbsoluteUrl(location.source.absoluteRef)
|
|
166
|
+
const relativePath = (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef)
|
|
167
167
|
? location.source.absoluteRef
|
|
168
168
|
: path.relative(cwd, location.source.absoluteRef);
|
|
169
|
-
const loc = codeframes_1.getLineColLocation(location);
|
|
169
|
+
const loc = (0, codeframes_1.getLineColLocation)(location);
|
|
170
170
|
const atPointer = location.pointer ? logger_1.colorize.gray(`at ${location.pointer}`) : '';
|
|
171
171
|
const fileWithLoc = `${relativePath}:${loc.start.line}:${loc.start.col}`;
|
|
172
172
|
return (`[${idx + 1}] ${bgColor(fileWithLoc)} ${atPointer}\n\n` +
|
|
173
173
|
`${problem.message}\n\n` +
|
|
174
174
|
formatDidYouMean(problem) +
|
|
175
|
-
codeframes_1.getCodeframe(loc, color) +
|
|
175
|
+
(0, codeframes_1.getCodeframe)(loc, color) +
|
|
176
176
|
'\n\n' +
|
|
177
177
|
formatFrom(cwd, problem.from) +
|
|
178
178
|
`${SEVERITY_NAMES[problem.severity]} was generated by the ${logger_1.colorize.blue(problem.ruleId)} rule.\n\n`);
|
|
@@ -216,7 +216,7 @@ function formatFrom(cwd, location) {
|
|
|
216
216
|
if (!location)
|
|
217
217
|
return '';
|
|
218
218
|
const relativePath = path.relative(cwd, location.source.absoluteRef);
|
|
219
|
-
const loc = codeframes_1.getLineColLocation(location);
|
|
219
|
+
const loc = (0, codeframes_1.getLineColLocation)(location);
|
|
220
220
|
const fileWithLoc = `${relativePath}:${loc.start.line}:${loc.start.col}`;
|
|
221
221
|
const atPointer = location.pointer ? logger_1.colorize.gray(`at ${location.pointer}`) : '';
|
|
222
222
|
return `referenced from ${logger_1.colorize.blue(fileWithLoc)} ${atPointer} \n\n`;
|
package/lib/js-yaml/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { LoadOptions, DumpOptions } from 'js-yaml';
|
|
2
|
-
export declare const parseYaml: (str: string, opts?: LoadOptions
|
|
3
|
-
export declare const stringifyYaml: (obj: any, opts?: DumpOptions
|
|
2
|
+
export declare const parseYaml: (str: string, opts?: LoadOptions) => unknown;
|
|
3
|
+
export declare const stringifyYaml: (obj: any, opts?: DumpOptions) => string;
|
package/lib/js-yaml/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = js_yaml_1.JSON_SCHEMA.extend({
|
|
|
9
9
|
implicit: [js_yaml_1.types.merge],
|
|
10
10
|
explicit: [js_yaml_1.types.binary, js_yaml_1.types.omap, js_yaml_1.types.pairs, js_yaml_1.types.set],
|
|
11
11
|
});
|
|
12
|
-
const parseYaml = (str, opts) => js_yaml_1.load(str, Object.assign({ schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP }, opts));
|
|
12
|
+
const parseYaml = (str, opts) => (0, js_yaml_1.load)(str, Object.assign({ schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP }, opts));
|
|
13
13
|
exports.parseYaml = parseYaml;
|
|
14
|
-
const stringifyYaml = (obj, opts) => js_yaml_1.dump(obj, opts);
|
|
14
|
+
const stringifyYaml = (obj, opts) => (0, js_yaml_1.dump)(obj, opts);
|
|
15
15
|
exports.stringifyYaml = stringifyYaml;
|