@redocly/openapi-core 1.0.0-beta.94 → 1.0.0-beta.97
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/__tests__/bundle.test.ts +6 -6
- package/__tests__/fixtures/extension.js +1 -1
- package/__tests__/login.test.ts +2 -2
- package/__tests__/ref-utils.test.ts +1 -1
- package/__tests__/utils.ts +30 -18
- package/lib/benchmark/benches/recommended-oas3.bench.js +2 -3
- package/lib/benchmark/utils.d.ts +2 -1
- package/lib/benchmark/utils.js +10 -7
- package/lib/bundle.d.ts +2 -2
- package/lib/config/all.d.ts +2 -2
- package/lib/config/builtIn.d.ts +1 -1
- package/lib/config/config-resolvers.d.ts +16 -0
- package/lib/config/config-resolvers.js +242 -0
- package/lib/config/config.d.ts +18 -130
- package/lib/config/config.js +34 -245
- package/lib/config/index.d.ts +7 -0
- package/lib/config/index.js +19 -0
- package/lib/config/load.d.ts +2 -1
- package/lib/config/load.js +20 -13
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/types.d.ts +113 -0
- package/lib/config/types.js +2 -0
- package/lib/config/utils.d.ts +13 -0
- package/lib/config/utils.js +160 -0
- package/lib/format/format.d.ts +1 -1
- package/lib/format/format.js +30 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +5 -6
- package/lib/lint.d.ts +1 -1
- package/lib/lint.js +5 -7
- package/lib/redocly/index.d.ts +1 -1
- package/lib/redocly/index.js +10 -26
- package/lib/redocly/redocly-client-types.d.ts +1 -1
- package/lib/redocly/registry-api-types.d.ts +1 -0
- package/lib/redocly/registry-api.d.ts +2 -2
- package/lib/redocly/registry-api.js +2 -1
- package/lib/resolve.d.ts +1 -1
- package/lib/resolve.js +1 -2
- package/lib/rules/common/assertions/index.js +1 -1
- package/lib/rules/common/assertions/utils.d.ts +1 -1
- package/lib/rules/common/assertions/utils.js +6 -2
- package/lib/utils.d.ts +4 -2
- package/lib/utils.js +20 -3
- package/package.json +9 -6
- package/src/__tests__/lint.test.ts +1 -1
- package/src/benchmark/benches/recommended-oas3.bench.ts +2 -3
- package/src/benchmark/benchmark.js +1 -1
- package/src/benchmark/utils.ts +13 -8
- package/src/bundle.ts +2 -1
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +157 -0
- package/src/config/__tests__/config-resolvers.test.ts +429 -0
- package/src/config/__tests__/config.test.ts +17 -29
- package/src/config/__tests__/fixtures/plugin.js +1 -1
- package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +12 -0
- package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +67 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-circular.yaml +8 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +19 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config.yaml +10 -0
- package/src/config/__tests__/fixtures/resolve-config/plugin.js +66 -0
- package/src/config/__tests__/fixtures/resolve-remote-configs/nested-remote-config.yaml +4 -0
- package/src/config/__tests__/fixtures/resolve-remote-configs/remote-config.yaml +5 -0
- package/src/config/__tests__/load.test.ts +8 -1
- package/src/config/all.ts +3 -2
- package/src/config/builtIn.ts +2 -1
- package/src/config/config-resolvers.ts +359 -0
- package/src/config/config.ts +60 -468
- package/src/config/index.ts +7 -0
- package/src/config/load.ts +37 -31
- package/src/config/minimal.ts +2 -2
- package/src/config/recommended.ts +2 -2
- package/src/config/types.ts +168 -0
- package/src/config/utils.ts +208 -0
- package/src/decorators/__tests__/remove-x-internal.test.ts +5 -5
- package/src/format/format.ts +38 -7
- package/src/index.ts +6 -2
- package/src/lint.ts +4 -5
- package/src/redocly/__tests__/redocly-client.test.ts +7 -0
- package/src/redocly/index.ts +14 -41
- package/src/redocly/redocly-client-types.ts +1 -1
- package/src/redocly/registry-api-types.ts +1 -0
- package/src/redocly/registry-api.ts +5 -1
- package/src/resolve.ts +2 -4
- package/src/rules/__tests__/no-unresolved-refs.test.ts +4 -4
- package/src/rules/common/__tests__/info-description.test.ts +3 -3
- package/src/rules/common/__tests__/info-license.test.ts +2 -2
- package/src/rules/common/__tests__/license-url.test.ts +2 -2
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +5 -5
- package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +3 -3
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +3 -3
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +3 -3
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +2 -2
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -1
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +4 -4
- package/src/rules/common/__tests__/operation-security-defined.test.ts +2 -2
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +2 -2
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +2 -2
- package/src/rules/common/__tests__/path-not-include-query.test.ts +2 -2
- package/src/rules/common/__tests__/path-params-defined.test.ts +3 -3
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +3 -3
- package/src/rules/common/__tests__/spec.test.ts +1 -1
- package/src/rules/common/__tests__/tag-description.test.ts +2 -2
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +2 -2
- package/src/rules/common/assertions/index.ts +1 -1
- package/src/rules/common/assertions/utils.ts +5 -2
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +3 -3
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -1
- package/src/rules/oas2/__tests__/spec/utils.ts +10 -7
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +6 -6
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +2 -2
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +8 -8
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +2 -2
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -1
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +23 -14
- package/src/rules/oas3/__tests__/spec/spec.test.ts +4 -4
- package/src/rules/oas3/__tests__/spec/utils.ts +10 -7
- package/src/utils.ts +21 -4
- package/tsconfig.tsbuildinfo +1 -1
package/lib/config/config.d.ts
CHANGED
|
@@ -1,107 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { NormalizedProblem } from '../walk';
|
|
3
|
+
import { OasVersion, OasMajorVersion, Oas2RuleSet, Oas3RuleSet } from '../oas-types';
|
|
4
|
+
import type { NodeType } from '../types';
|
|
5
|
+
import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedLintConfig, RuleConfig } from './types';
|
|
6
|
+
export declare const env: NodeJS.ProcessEnv;
|
|
4
7
|
export declare const IGNORE_FILE = ".redocly.lint-ignore.yaml";
|
|
5
|
-
export declare type RuleConfig = ProblemSeverity | 'off' | ({
|
|
6
|
-
severity?: ProblemSeverity;
|
|
7
|
-
} & Record<string, any>);
|
|
8
|
-
export declare type PreprocessorConfig = ProblemSeverity | 'off' | 'on' | ({
|
|
9
|
-
severity?: ProblemSeverity;
|
|
10
|
-
} & Record<string, any>);
|
|
11
|
-
export declare type DecoratorConfig = PreprocessorConfig;
|
|
12
|
-
export declare type LintRawConfig = {
|
|
13
|
-
plugins?: (string | Plugin)[];
|
|
14
|
-
extends?: string[];
|
|
15
|
-
doNotResolveExamples?: boolean;
|
|
16
|
-
rules?: Record<string, RuleConfig>;
|
|
17
|
-
oas2Rules?: Record<string, RuleConfig>;
|
|
18
|
-
oas3_0Rules?: Record<string, RuleConfig>;
|
|
19
|
-
oas3_1Rules?: Record<string, RuleConfig>;
|
|
20
|
-
preprocessors?: Record<string, PreprocessorConfig>;
|
|
21
|
-
oas2Preprocessors?: Record<string, PreprocessorConfig>;
|
|
22
|
-
oas3_0Preprocessors?: Record<string, PreprocessorConfig>;
|
|
23
|
-
oas3_1Preprocessors?: Record<string, PreprocessorConfig>;
|
|
24
|
-
decorators?: Record<string, DecoratorConfig>;
|
|
25
|
-
oas2Decorators?: Record<string, DecoratorConfig>;
|
|
26
|
-
oas3_0Decorators?: Record<string, DecoratorConfig>;
|
|
27
|
-
oas3_1Decorators?: Record<string, DecoratorConfig>;
|
|
28
|
-
};
|
|
29
|
-
export declare type PreprocessorsConfig = {
|
|
30
|
-
oas3?: Oas3PreprocessorsSet;
|
|
31
|
-
oas2?: Oas2PreprocessorsSet;
|
|
32
|
-
};
|
|
33
|
-
export declare type DecoratorsConfig = {
|
|
34
|
-
oas3?: Oas3DecoratorsSet;
|
|
35
|
-
oas2?: Oas2DecoratorsSet;
|
|
36
|
-
};
|
|
37
|
-
export declare type TypesExtensionFn = (types: Record<string, NodeType>, oasVersion: OasVersion) => Record<string, NodeType>;
|
|
38
|
-
export declare type TypeExtensionsConfig = Partial<Record<OasMajorVersion, TypesExtensionFn>>;
|
|
39
|
-
export declare type CustomRulesConfig = {
|
|
40
|
-
oas3?: Oas3RuleSet;
|
|
41
|
-
oas2?: Oas2RuleSet;
|
|
42
|
-
};
|
|
43
|
-
export declare type Plugin = {
|
|
44
|
-
id: string;
|
|
45
|
-
configs?: Record<string, LintRawConfig>;
|
|
46
|
-
rules?: CustomRulesConfig;
|
|
47
|
-
preprocessors?: PreprocessorsConfig;
|
|
48
|
-
decorators?: DecoratorsConfig;
|
|
49
|
-
typeExtension?: TypeExtensionsConfig;
|
|
50
|
-
};
|
|
51
|
-
export declare type ResolveHeader = {
|
|
52
|
-
name: string;
|
|
53
|
-
envVariable?: undefined;
|
|
54
|
-
value: string;
|
|
55
|
-
matches: string;
|
|
56
|
-
} | {
|
|
57
|
-
name: string;
|
|
58
|
-
value?: undefined;
|
|
59
|
-
envVariable: string;
|
|
60
|
-
matches: string;
|
|
61
|
-
};
|
|
62
|
-
export declare type RawResolveConfig = {
|
|
63
|
-
http?: Partial<HttpResolveConfig>;
|
|
64
|
-
};
|
|
65
|
-
export declare type HttpResolveConfig = {
|
|
66
|
-
headers: ResolveHeader[];
|
|
67
|
-
customFetch?: Function;
|
|
68
|
-
};
|
|
69
|
-
export declare type ResolveConfig = {
|
|
70
|
-
http: HttpResolveConfig;
|
|
71
|
-
};
|
|
72
8
|
export declare const DEFAULT_REGION = "us";
|
|
73
|
-
export declare type Region = 'us' | 'eu';
|
|
74
|
-
export declare type AccessTokens = {
|
|
75
|
-
[region in Region]?: string;
|
|
76
|
-
};
|
|
77
9
|
export declare const DOMAINS: {
|
|
78
|
-
|
|
10
|
+
us: string;
|
|
11
|
+
eu: string;
|
|
79
12
|
};
|
|
80
13
|
export declare const AVAILABLE_REGIONS: Region[];
|
|
81
|
-
export declare type DeprecatedRawConfig = {
|
|
82
|
-
apiDefinitions?: Record<string, string>;
|
|
83
|
-
lint?: LintRawConfig;
|
|
84
|
-
resolve?: RawResolveConfig;
|
|
85
|
-
region?: Region;
|
|
86
|
-
referenceDocs?: Record<string, any>;
|
|
87
|
-
};
|
|
88
|
-
export declare type Api = {
|
|
89
|
-
root: string;
|
|
90
|
-
lint?: Omit<LintRawConfig, 'plugins'>;
|
|
91
|
-
'features.openapi'?: Record<string, any>;
|
|
92
|
-
'features.mockServer'?: Record<string, any>;
|
|
93
|
-
};
|
|
94
|
-
export declare type RawConfig = {
|
|
95
|
-
apis?: Record<string, Api>;
|
|
96
|
-
lint?: LintRawConfig;
|
|
97
|
-
resolve?: RawResolveConfig;
|
|
98
|
-
region?: Region;
|
|
99
|
-
'features.openapi'?: Record<string, any>;
|
|
100
|
-
'features.mockServer'?: Record<string, any>;
|
|
101
|
-
organization?: string;
|
|
102
|
-
};
|
|
103
14
|
export declare class LintConfig {
|
|
104
|
-
rawConfig:
|
|
15
|
+
rawConfig: ResolvedLintConfig;
|
|
105
16
|
configFile?: string | undefined;
|
|
106
17
|
plugins: Plugin[];
|
|
107
18
|
ignore: Record<string, Record<string, Set<string>>>;
|
|
@@ -112,19 +23,21 @@ export declare class LintConfig {
|
|
|
112
23
|
private _usedRules;
|
|
113
24
|
private _usedVersions;
|
|
114
25
|
recommendedFallback: boolean;
|
|
115
|
-
|
|
26
|
+
extendPaths: string[];
|
|
27
|
+
pluginPaths: string[];
|
|
28
|
+
constructor(rawConfig: ResolvedLintConfig, configFile?: string | undefined);
|
|
116
29
|
saveIgnore(): void;
|
|
117
30
|
addIgnore(problem: NormalizedProblem): void;
|
|
118
31
|
addProblemToIgnore(problem: NormalizedProblem): NormalizedProblem;
|
|
119
32
|
extendTypes(types: Record<string, NodeType>, version: OasVersion): Record<string, NodeType>;
|
|
120
33
|
getRuleSettings(ruleId: string, oasVersion: OasVersion): {
|
|
121
|
-
severity: ProblemSeverity | "off";
|
|
34
|
+
severity: import("../walk").ProblemSeverity | "off";
|
|
122
35
|
};
|
|
123
36
|
getPreprocessorSettings(ruleId: string, oasVersion: OasVersion): {
|
|
124
|
-
severity: ProblemSeverity | "off";
|
|
37
|
+
severity: import("../walk").ProblemSeverity | "off";
|
|
125
38
|
};
|
|
126
39
|
getDecoratorSettings(ruleId: string, oasVersion: OasVersion): {
|
|
127
|
-
severity: ProblemSeverity | "off";
|
|
40
|
+
severity: import("../walk").ProblemSeverity | "off";
|
|
128
41
|
};
|
|
129
42
|
getUnusedRules(): {
|
|
130
43
|
rules: string[];
|
|
@@ -137,9 +50,9 @@ export declare class LintConfig {
|
|
|
137
50
|
skipDecorators(decorators?: string[]): void;
|
|
138
51
|
}
|
|
139
52
|
export declare class Config {
|
|
140
|
-
rawConfig:
|
|
53
|
+
rawConfig: ResolvedConfig;
|
|
141
54
|
configFile?: string | undefined;
|
|
142
|
-
apis: Record<string,
|
|
55
|
+
apis: Record<string, ResolvedApi>;
|
|
143
56
|
lint: LintConfig;
|
|
144
57
|
resolve: ResolveConfig;
|
|
145
58
|
licenseKey?: string;
|
|
@@ -147,30 +60,5 @@ export declare class Config {
|
|
|
147
60
|
'features.openapi': Record<string, any>;
|
|
148
61
|
'features.mockServer'?: Record<string, any>;
|
|
149
62
|
organization?: string;
|
|
150
|
-
constructor(rawConfig:
|
|
63
|
+
constructor(rawConfig: ResolvedConfig, configFile?: string | undefined);
|
|
151
64
|
}
|
|
152
|
-
export declare function getMergedConfig(config: Config, entrypointAlias?: string): Config;
|
|
153
|
-
export declare function getMergedLintConfig(config: Config, entrypointAlias?: string): {
|
|
154
|
-
rules: {
|
|
155
|
-
[x: string]: RuleConfig;
|
|
156
|
-
};
|
|
157
|
-
preprocessors: {
|
|
158
|
-
[x: string]: PreprocessorConfig;
|
|
159
|
-
};
|
|
160
|
-
decorators: {
|
|
161
|
-
[x: string]: PreprocessorConfig;
|
|
162
|
-
};
|
|
163
|
-
extends?: string[] | undefined;
|
|
164
|
-
doNotResolveExamples?: boolean | undefined;
|
|
165
|
-
oas2Rules?: Record<string, RuleConfig> | undefined;
|
|
166
|
-
oas3_0Rules?: Record<string, RuleConfig> | undefined;
|
|
167
|
-
oas3_1Rules?: Record<string, RuleConfig> | undefined;
|
|
168
|
-
oas2Preprocessors?: Record<string, PreprocessorConfig> | undefined;
|
|
169
|
-
oas3_0Preprocessors?: Record<string, PreprocessorConfig> | undefined;
|
|
170
|
-
oas3_1Preprocessors?: Record<string, PreprocessorConfig> | undefined;
|
|
171
|
-
oas2Decorators?: Record<string, PreprocessorConfig> | undefined;
|
|
172
|
-
oas3_0Decorators?: Record<string, PreprocessorConfig> | undefined;
|
|
173
|
-
oas3_1Decorators?: Record<string, PreprocessorConfig> | undefined;
|
|
174
|
-
plugins?: (string | Plugin)[] | undefined;
|
|
175
|
-
};
|
|
176
|
-
export declare function transformConfig(rawConfig: DeprecatedRawConfig | RawConfig): RawConfig;
|
package/lib/config/config.js
CHANGED
|
@@ -1,41 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
3
|
+
exports.Config = exports.LintConfig = exports.AVAILABLE_REGIONS = exports.DOMAINS = exports.DEFAULT_REGION = exports.IGNORE_FILE = exports.env = void 0;
|
|
15
4
|
const fs = require("fs");
|
|
16
5
|
const path = require("path");
|
|
17
|
-
const path_1 = require("path");
|
|
18
|
-
const colorette_1 = require("colorette");
|
|
19
6
|
const js_yaml_1 = require("../js-yaml");
|
|
20
7
|
const utils_1 = require("../utils");
|
|
21
8
|
const oas_types_1 = require("../oas-types");
|
|
22
|
-
const
|
|
9
|
+
const utils_2 = require("./utils");
|
|
10
|
+
// Alias environment here so this file can work in browser environments too.
|
|
11
|
+
exports.env = typeof process !== 'undefined' ? process.env || {} : {};
|
|
23
12
|
exports.IGNORE_FILE = '.redocly.lint-ignore.yaml';
|
|
24
13
|
const IGNORE_BANNER = `# This file instructs Redocly's linter to ignore the rules contained for specific parts of your API.\n` +
|
|
25
14
|
`# See https://redoc.ly/docs/cli/ for more information.\n`;
|
|
26
15
|
exports.DEFAULT_REGION = 'us';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
// FIXME: temporary fix for our lab environments
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
function getDomains() {
|
|
17
|
+
const domains = {
|
|
18
|
+
us: 'redocly.com',
|
|
19
|
+
eu: 'eu.redocly.com',
|
|
20
|
+
};
|
|
21
|
+
// FIXME: temporary fix for our lab environments
|
|
22
|
+
const domain = exports.env.REDOCLY_DOMAIN;
|
|
23
|
+
if (domain === null || domain === void 0 ? void 0 : domain.endsWith('.redocly.host')) {
|
|
24
|
+
domains[domain.split('.')[0]] = domain;
|
|
25
|
+
}
|
|
26
|
+
if (domain === 'redoc.online') {
|
|
27
|
+
domains[domain] = domain;
|
|
28
|
+
}
|
|
29
|
+
return domains;
|
|
38
30
|
}
|
|
31
|
+
exports.DOMAINS = getDomains();
|
|
39
32
|
exports.AVAILABLE_REGIONS = Object.keys(exports.DOMAINS);
|
|
40
33
|
class LintConfig {
|
|
41
34
|
constructor(rawConfig, configFile) {
|
|
@@ -44,38 +37,26 @@ class LintConfig {
|
|
|
44
37
|
this.ignore = {};
|
|
45
38
|
this._usedRules = new Set();
|
|
46
39
|
this._usedVersions = new Set();
|
|
47
|
-
this.
|
|
48
|
-
this.plugins = rawConfig.plugins ? resolvePlugins(rawConfig.plugins, configFile) : [];
|
|
40
|
+
this.plugins = rawConfig.plugins || [];
|
|
49
41
|
this.doNotResolveExamples = !!rawConfig.doNotResolveExamples;
|
|
50
|
-
|
|
51
|
-
this.recommendedFallback = true;
|
|
52
|
-
}
|
|
53
|
-
const extendConfigs = rawConfig.extends
|
|
54
|
-
? resolvePresets(rawConfig.extends, this.plugins)
|
|
55
|
-
: [recommended_1.default];
|
|
56
|
-
if (rawConfig.rules || rawConfig.preprocessors || rawConfig.decorators) {
|
|
57
|
-
extendConfigs.push({
|
|
58
|
-
rules: rawConfig.rules,
|
|
59
|
-
preprocessors: rawConfig.preprocessors,
|
|
60
|
-
decorators: rawConfig.decorators,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
const merged = mergeExtends(extendConfigs);
|
|
42
|
+
this.recommendedFallback = rawConfig.recommendedFallback || false;
|
|
64
43
|
this.rules = {
|
|
65
|
-
[oas_types_1.OasVersion.Version2]: Object.assign(Object.assign({},
|
|
66
|
-
[oas_types_1.OasVersion.Version3_0]: Object.assign(Object.assign({},
|
|
67
|
-
[oas_types_1.OasVersion.Version3_1]: Object.assign(Object.assign({},
|
|
44
|
+
[oas_types_1.OasVersion.Version2]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas2Rules),
|
|
45
|
+
[oas_types_1.OasVersion.Version3_0]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas3_0Rules),
|
|
46
|
+
[oas_types_1.OasVersion.Version3_1]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas3_1Rules),
|
|
68
47
|
};
|
|
69
48
|
this.preprocessors = {
|
|
70
|
-
[oas_types_1.OasVersion.Version2]: Object.assign(Object.assign({},
|
|
71
|
-
[oas_types_1.OasVersion.Version3_0]: Object.assign(Object.assign({},
|
|
72
|
-
[oas_types_1.OasVersion.Version3_1]: Object.assign(Object.assign({},
|
|
49
|
+
[oas_types_1.OasVersion.Version2]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas2Preprocessors),
|
|
50
|
+
[oas_types_1.OasVersion.Version3_0]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas3_0Preprocessors),
|
|
51
|
+
[oas_types_1.OasVersion.Version3_1]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas3_1Preprocessors),
|
|
73
52
|
};
|
|
74
53
|
this.decorators = {
|
|
75
|
-
[oas_types_1.OasVersion.Version2]: Object.assign(Object.assign({},
|
|
76
|
-
[oas_types_1.OasVersion.Version3_0]: Object.assign(Object.assign({},
|
|
77
|
-
[oas_types_1.OasVersion.Version3_1]: Object.assign(Object.assign({},
|
|
54
|
+
[oas_types_1.OasVersion.Version2]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas2Decorators),
|
|
55
|
+
[oas_types_1.OasVersion.Version3_0]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas3_0Decorators),
|
|
56
|
+
[oas_types_1.OasVersion.Version3_1]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas3_1Decorators),
|
|
78
57
|
};
|
|
58
|
+
this.extendPaths = rawConfig.extendPaths || [];
|
|
59
|
+
this.pluginPaths = rawConfig.pluginPaths || [];
|
|
79
60
|
const dir = this.configFile
|
|
80
61
|
? path.dirname(this.configFile)
|
|
81
62
|
: (typeof process !== 'undefined' && process.cwd()) || '';
|
|
@@ -87,7 +68,7 @@ class LintConfig {
|
|
|
87
68
|
js_yaml_1.parseYaml(fs.readFileSync(ignoreFile, 'utf-8')) || {};
|
|
88
69
|
// resolve ignore paths
|
|
89
70
|
for (const fileName of Object.keys(this.ignore)) {
|
|
90
|
-
this.ignore[path.resolve(
|
|
71
|
+
this.ignore[path.resolve(path.dirname(ignoreFile), fileName)] = this.ignore[fileName];
|
|
91
72
|
for (const ruleId of Object.keys(this.ignore[fileName])) {
|
|
92
73
|
this.ignore[fileName][ruleId] = new Set(this.ignore[fileName][ruleId]);
|
|
93
74
|
}
|
|
@@ -249,207 +230,15 @@ class LintConfig {
|
|
|
249
230
|
exports.LintConfig = LintConfig;
|
|
250
231
|
class Config {
|
|
251
232
|
constructor(rawConfig, configFile) {
|
|
252
|
-
var _a, _b, _c;
|
|
253
233
|
this.rawConfig = rawConfig;
|
|
254
234
|
this.configFile = configFile;
|
|
255
235
|
this.apis = rawConfig.apis || {};
|
|
256
236
|
this.lint = new LintConfig(rawConfig.lint || {}, configFile);
|
|
257
237
|
this['features.openapi'] = rawConfig['features.openapi'] || {};
|
|
258
238
|
this['features.mockServer'] = rawConfig['features.mockServer'] || {};
|
|
259
|
-
this.resolve =
|
|
260
|
-
http: {
|
|
261
|
-
headers: (_c = (_b = (_a = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.resolve) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.headers) !== null && _c !== void 0 ? _c : [],
|
|
262
|
-
customFetch: undefined,
|
|
263
|
-
},
|
|
264
|
-
};
|
|
239
|
+
this.resolve = utils_2.getResolveConfig(rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.resolve);
|
|
265
240
|
this.region = rawConfig.region;
|
|
266
241
|
this.organization = rawConfig.organization;
|
|
267
242
|
}
|
|
268
243
|
}
|
|
269
244
|
exports.Config = Config;
|
|
270
|
-
function resolvePresets(presets, plugins) {
|
|
271
|
-
return presets.map((presetName) => {
|
|
272
|
-
var _a;
|
|
273
|
-
const { pluginId, configName } = parsePresetName(presetName);
|
|
274
|
-
const plugin = plugins.find((p) => p.id === pluginId);
|
|
275
|
-
if (!plugin) {
|
|
276
|
-
throw new Error(`Invalid config ${colorette_1.red(presetName)}: plugin ${pluginId} is not included.`);
|
|
277
|
-
}
|
|
278
|
-
const preset = (_a = plugin.configs) === null || _a === void 0 ? void 0 : _a[configName];
|
|
279
|
-
if (!preset) {
|
|
280
|
-
throw new Error(pluginId
|
|
281
|
-
? `Invalid config ${colorette_1.red(presetName)}: plugin ${pluginId} doesn't export config with name ${configName}.`
|
|
282
|
-
: `Invalid config ${colorette_1.red(presetName)}: there is no such built-in config.`);
|
|
283
|
-
}
|
|
284
|
-
return preset;
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
function parsePresetName(presetName) {
|
|
288
|
-
if (presetName.indexOf('/') > -1) {
|
|
289
|
-
const [pluginId, configName] = presetName.split('/');
|
|
290
|
-
return { pluginId, configName };
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
return { pluginId: '', configName: presetName };
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
function resolvePlugins(plugins, configPath = '') {
|
|
297
|
-
if (!plugins)
|
|
298
|
-
return [];
|
|
299
|
-
// @ts-ignore
|
|
300
|
-
const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
|
|
301
|
-
const seenPluginIds = new Map();
|
|
302
|
-
return plugins
|
|
303
|
-
.map((p) => {
|
|
304
|
-
// TODO: resolve npm packages similar to eslint
|
|
305
|
-
const pluginModule = typeof p === 'string'
|
|
306
|
-
? requireFunc(path.resolve(path.dirname(configPath), p))
|
|
307
|
-
: p;
|
|
308
|
-
const id = pluginModule.id;
|
|
309
|
-
if (typeof id !== 'string') {
|
|
310
|
-
throw new Error(colorette_1.red(`Plugin must define \`id\` property in ${colorette_1.blue(p.toString())}.`));
|
|
311
|
-
}
|
|
312
|
-
if (seenPluginIds.has(id)) {
|
|
313
|
-
const pluginPath = seenPluginIds.get(id);
|
|
314
|
-
throw new Error(colorette_1.red(`Plugin "id" must be unique. Plugin ${colorette_1.blue(p.toString())} uses id "${colorette_1.blue(id)}" already seen in ${colorette_1.blue(pluginPath)}`));
|
|
315
|
-
}
|
|
316
|
-
seenPluginIds.set(id, p.toString());
|
|
317
|
-
const plugin = Object.assign(Object.assign({ id }, (pluginModule.configs ? { configs: pluginModule.configs } : {})), (pluginModule.typeExtension ? { typeExtension: pluginModule.typeExtension } : {}));
|
|
318
|
-
if (pluginModule.rules) {
|
|
319
|
-
if (!pluginModule.rules.oas3 && !pluginModule.rules.oas2) {
|
|
320
|
-
throw new Error(`Plugin rules must have \`oas3\` or \`oas2\` rules "${p}.`);
|
|
321
|
-
}
|
|
322
|
-
plugin.rules = {};
|
|
323
|
-
if (pluginModule.rules.oas3) {
|
|
324
|
-
plugin.rules.oas3 = prefixRules(pluginModule.rules.oas3, id);
|
|
325
|
-
}
|
|
326
|
-
if (pluginModule.rules.oas2) {
|
|
327
|
-
plugin.rules.oas2 = prefixRules(pluginModule.rules.oas2, id);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (pluginModule.preprocessors) {
|
|
331
|
-
if (!pluginModule.preprocessors.oas3 && !pluginModule.preprocessors.oas2) {
|
|
332
|
-
throw new Error(`Plugin \`preprocessors\` must have \`oas3\` or \`oas2\` preprocessors "${p}.`);
|
|
333
|
-
}
|
|
334
|
-
plugin.preprocessors = {};
|
|
335
|
-
if (pluginModule.preprocessors.oas3) {
|
|
336
|
-
plugin.preprocessors.oas3 = prefixRules(pluginModule.preprocessors.oas3, id);
|
|
337
|
-
}
|
|
338
|
-
if (pluginModule.preprocessors.oas2) {
|
|
339
|
-
plugin.preprocessors.oas2 = prefixRules(pluginModule.preprocessors.oas2, id);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
if (pluginModule.decorators) {
|
|
343
|
-
if (!pluginModule.decorators.oas3 && !pluginModule.decorators.oas2) {
|
|
344
|
-
throw new Error(`Plugin \`decorators\` must have \`oas3\` or \`oas2\` decorators "${p}.`);
|
|
345
|
-
}
|
|
346
|
-
plugin.decorators = {};
|
|
347
|
-
if (pluginModule.decorators.oas3) {
|
|
348
|
-
plugin.decorators.oas3 = prefixRules(pluginModule.decorators.oas3, id);
|
|
349
|
-
}
|
|
350
|
-
if (pluginModule.decorators.oas2) {
|
|
351
|
-
plugin.decorators.oas2 = prefixRules(pluginModule.decorators.oas2, id);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
return plugin;
|
|
355
|
-
})
|
|
356
|
-
.filter(utils_1.notUndefined);
|
|
357
|
-
}
|
|
358
|
-
function prefixRules(rules, prefix) {
|
|
359
|
-
if (!prefix)
|
|
360
|
-
return rules;
|
|
361
|
-
const res = {};
|
|
362
|
-
for (const name of Object.keys(rules)) {
|
|
363
|
-
res[`${prefix}/${name}`] = rules[name];
|
|
364
|
-
}
|
|
365
|
-
return res;
|
|
366
|
-
}
|
|
367
|
-
function mergeExtends(rulesConfList) {
|
|
368
|
-
const result = {
|
|
369
|
-
rules: {},
|
|
370
|
-
oas2Rules: {},
|
|
371
|
-
oas3_0Rules: {},
|
|
372
|
-
oas3_1Rules: {},
|
|
373
|
-
preprocessors: {},
|
|
374
|
-
oas2Preprocessors: {},
|
|
375
|
-
oas3_0Preprocessors: {},
|
|
376
|
-
oas3_1Preprocessors: {},
|
|
377
|
-
decorators: {},
|
|
378
|
-
oas2Decorators: {},
|
|
379
|
-
oas3_0Decorators: {},
|
|
380
|
-
oas3_1Decorators: {},
|
|
381
|
-
};
|
|
382
|
-
for (let rulesConf of rulesConfList) {
|
|
383
|
-
if (rulesConf.extends) {
|
|
384
|
-
throw new Error(`\`extends\` is not supported in shared configs yet: ${JSON.stringify(rulesConf, null, 2)}.`);
|
|
385
|
-
}
|
|
386
|
-
Object.assign(result.rules, rulesConf.rules);
|
|
387
|
-
Object.assign(result.oas2Rules, rulesConf.oas2Rules);
|
|
388
|
-
assignExisting(result.oas2Rules, rulesConf.rules || {});
|
|
389
|
-
Object.assign(result.oas3_0Rules, rulesConf.oas3_0Rules);
|
|
390
|
-
assignExisting(result.oas3_0Rules, rulesConf.rules || {});
|
|
391
|
-
Object.assign(result.oas3_1Rules, rulesConf.oas3_1Rules);
|
|
392
|
-
assignExisting(result.oas3_1Rules, rulesConf.rules || {});
|
|
393
|
-
Object.assign(result.preprocessors, rulesConf.preprocessors);
|
|
394
|
-
Object.assign(result.oas2Preprocessors, rulesConf.oas2Preprocessors);
|
|
395
|
-
assignExisting(result.oas2Preprocessors, rulesConf.preprocessors || {});
|
|
396
|
-
Object.assign(result.oas3_0Preprocessors, rulesConf.oas3_0Preprocessors);
|
|
397
|
-
assignExisting(result.oas3_0Preprocessors, rulesConf.preprocessors || {});
|
|
398
|
-
Object.assign(result.oas3_1Preprocessors, rulesConf.oas3_1Preprocessors);
|
|
399
|
-
assignExisting(result.oas3_1Preprocessors, rulesConf.preprocessors || {});
|
|
400
|
-
Object.assign(result.decorators, rulesConf.decorators);
|
|
401
|
-
Object.assign(result.oas2Decorators, rulesConf.oas2Decorators);
|
|
402
|
-
assignExisting(result.oas2Decorators, rulesConf.decorators || {});
|
|
403
|
-
Object.assign(result.oas3_0Decorators, rulesConf.oas3_0Decorators);
|
|
404
|
-
assignExisting(result.oas3_0Decorators, rulesConf.decorators || {});
|
|
405
|
-
Object.assign(result.oas3_1Decorators, rulesConf.oas3_1Decorators);
|
|
406
|
-
assignExisting(result.oas3_1Decorators, rulesConf.decorators || {});
|
|
407
|
-
}
|
|
408
|
-
return result;
|
|
409
|
-
}
|
|
410
|
-
function assignExisting(target, obj) {
|
|
411
|
-
for (let k of Object.keys(obj)) {
|
|
412
|
-
if (target.hasOwnProperty(k)) {
|
|
413
|
-
target[k] = obj[k];
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
function getMergedConfig(config, entrypointAlias) {
|
|
418
|
-
var _a, _b;
|
|
419
|
-
return entrypointAlias
|
|
420
|
-
? new Config(Object.assign(Object.assign({}, config.rawConfig), { lint: getMergedLintConfig(config, entrypointAlias), 'features.openapi': Object.assign(Object.assign({}, config['features.openapi']), (_a = config.apis[entrypointAlias]) === null || _a === void 0 ? void 0 : _a['features.openapi']), 'features.mockServer': Object.assign(Object.assign({}, config['features.mockServer']), (_b = config.apis[entrypointAlias]) === null || _b === void 0 ? void 0 : _b['features.mockServer']) }), config.configFile)
|
|
421
|
-
: config;
|
|
422
|
-
}
|
|
423
|
-
exports.getMergedConfig = getMergedConfig;
|
|
424
|
-
function getMergedLintConfig(config, entrypointAlias) {
|
|
425
|
-
var _a, _b, _c, _d;
|
|
426
|
-
const apiLint = entrypointAlias ? (_a = config.apis[entrypointAlias]) === null || _a === void 0 ? void 0 : _a.lint : {};
|
|
427
|
-
const mergedLint = Object.assign(Object.assign(Object.assign({}, config.rawConfig.lint), apiLint), { rules: Object.assign(Object.assign({}, (_b = config.rawConfig.lint) === null || _b === void 0 ? void 0 : _b.rules), apiLint === null || apiLint === void 0 ? void 0 : apiLint.rules), preprocessors: Object.assign(Object.assign({}, (_c = config.rawConfig.lint) === null || _c === void 0 ? void 0 : _c.preprocessors), apiLint === null || apiLint === void 0 ? void 0 : apiLint.preprocessors), decorators: Object.assign(Object.assign({}, (_d = config.rawConfig.lint) === null || _d === void 0 ? void 0 : _d.decorators), apiLint === null || apiLint === void 0 ? void 0 : apiLint.decorators) });
|
|
428
|
-
return mergedLint;
|
|
429
|
-
}
|
|
430
|
-
exports.getMergedLintConfig = getMergedLintConfig;
|
|
431
|
-
function transformApiDefinitionsToApis(apiDefinitions = {}) {
|
|
432
|
-
let apis = {};
|
|
433
|
-
for (const [apiName, apiPath] of Object.entries(apiDefinitions)) {
|
|
434
|
-
apis[apiName] = { root: apiPath };
|
|
435
|
-
}
|
|
436
|
-
return apis;
|
|
437
|
-
}
|
|
438
|
-
function transformConfig(rawConfig) {
|
|
439
|
-
if (rawConfig.apis && rawConfig.apiDefinitions) {
|
|
440
|
-
throw new Error("Do not use 'apiDefinitions' field. Use 'apis' instead.\n");
|
|
441
|
-
}
|
|
442
|
-
if (rawConfig['features.openapi'] &&
|
|
443
|
-
rawConfig.referenceDocs) {
|
|
444
|
-
throw new Error("Do not use 'referenceDocs' field. Use 'features.openapi' instead.\n");
|
|
445
|
-
}
|
|
446
|
-
const _a = rawConfig, { apiDefinitions, referenceDocs } = _a, rest = __rest(_a, ["apiDefinitions", "referenceDocs"]);
|
|
447
|
-
if (apiDefinitions) {
|
|
448
|
-
process.stderr.write(`The ${colorette_1.yellow('apiDefinitions')} field is deprecated. Use ${colorette_1.green('apis')} instead. Read more about this change: https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties\n`);
|
|
449
|
-
}
|
|
450
|
-
if (referenceDocs) {
|
|
451
|
-
process.stderr.write(`The ${colorette_1.yellow('referenceDocs')} field is deprecated. Use ${colorette_1.green('features.openapi')} instead. Read more about this change: https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties\n`);
|
|
452
|
-
}
|
|
453
|
-
return Object.assign({ 'features.openapi': referenceDocs, apis: transformApiDefinitionsToApis(apiDefinitions) }, rest);
|
|
454
|
-
}
|
|
455
|
-
exports.transformConfig = transformConfig;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./config"), exports);
|
|
14
|
+
__exportStar(require("./types"), exports);
|
|
15
|
+
__exportStar(require("./rules"), exports);
|
|
16
|
+
__exportStar(require("./builtIn"), exports);
|
|
17
|
+
__exportStar(require("./load"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./config-resolvers"), exports);
|
package/lib/config/load.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Config
|
|
1
|
+
import { Config } from './config';
|
|
2
|
+
import type { RawConfig } from './types';
|
|
2
3
|
export declare function loadConfig(configPath?: string | undefined, customExtends?: string[]): Promise<Config>;
|
|
3
4
|
export declare const CONFIG_FILE_NAMES: string[];
|
|
4
5
|
export declare function findConfig(dir?: string): string | undefined;
|
package/lib/config/load.js
CHANGED
|
@@ -15,15 +15,20 @@ const path = require("path");
|
|
|
15
15
|
const redocly_1 = require("../redocly");
|
|
16
16
|
const utils_1 = require("../utils");
|
|
17
17
|
const config_1 = require("./config");
|
|
18
|
-
const
|
|
18
|
+
const utils_2 = require("./utils");
|
|
19
|
+
const config_resolvers_1 = require("./config-resolvers");
|
|
19
20
|
function loadConfig(configPath = findConfig(), customExtends) {
|
|
20
|
-
var _a
|
|
21
|
+
var _a;
|
|
21
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
const rawConfig = yield getConfig(configPath);
|
|
23
24
|
if (customExtends !== undefined) {
|
|
24
25
|
rawConfig.lint = rawConfig.lint || {};
|
|
25
26
|
rawConfig.lint.extends = customExtends;
|
|
26
27
|
}
|
|
28
|
+
else if (utils_1.isEmptyObject(rawConfig)) {
|
|
29
|
+
// TODO: check if we can add recommended here. add message here?
|
|
30
|
+
// rawConfig.lint = { extends: ['recommended'], recommendedFallback: true };
|
|
31
|
+
}
|
|
27
32
|
const redoclyClient = new redocly_1.RedoclyClient();
|
|
28
33
|
const tokens = yield redoclyClient.getTokens();
|
|
29
34
|
if (tokens.length) {
|
|
@@ -41,15 +46,19 @@ function loadConfig(configPath = findConfig(), customExtends) {
|
|
|
41
46
|
value: item.token,
|
|
42
47
|
},
|
|
43
48
|
//support redocly.com domain for future compatibility
|
|
44
|
-
...(item.region === 'us'
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
...(item.region === 'us'
|
|
50
|
+
? [
|
|
51
|
+
{
|
|
52
|
+
matches: `https://api.redoc.ly/registry/**`,
|
|
53
|
+
name: 'Authorization',
|
|
54
|
+
envVariable: undefined,
|
|
55
|
+
value: item.token,
|
|
56
|
+
},
|
|
57
|
+
]
|
|
58
|
+
: []));
|
|
50
59
|
}
|
|
51
60
|
}
|
|
52
|
-
return
|
|
61
|
+
return config_resolvers_1.resolveConfig(rawConfig, configPath);
|
|
53
62
|
});
|
|
54
63
|
}
|
|
55
64
|
exports.loadConfig = loadConfig;
|
|
@@ -57,9 +66,7 @@ exports.CONFIG_FILE_NAMES = ['redocly.yaml', 'redocly.yml', '.redocly.yaml', '.r
|
|
|
57
66
|
function findConfig(dir) {
|
|
58
67
|
if (!fs.hasOwnProperty('existsSync'))
|
|
59
68
|
return;
|
|
60
|
-
const existingConfigFiles = exports.CONFIG_FILE_NAMES
|
|
61
|
-
.map(name => dir ? path.resolve(dir, name) : name)
|
|
62
|
-
.filter(fs.existsSync);
|
|
69
|
+
const existingConfigFiles = exports.CONFIG_FILE_NAMES.map((name) => dir ? path.resolve(dir, name) : name).filter(fs.existsSync);
|
|
63
70
|
if (existingConfigFiles.length > 1) {
|
|
64
71
|
throw new Error(`
|
|
65
72
|
Multiple configuration files are not allowed.
|
|
@@ -76,7 +83,7 @@ function getConfig(configPath = findConfig()) {
|
|
|
76
83
|
return {};
|
|
77
84
|
try {
|
|
78
85
|
const rawConfig = ((yield utils_1.loadYaml(configPath)) || {});
|
|
79
|
-
return
|
|
86
|
+
return utils_2.transformConfig(rawConfig);
|
|
80
87
|
}
|
|
81
88
|
catch (e) {
|
|
82
89
|
throw new Error(`Error parsing config file at '${configPath}': ${e.message}`);
|
package/lib/config/minimal.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default:
|
|
1
|
+
import type { PluginLintConfig } from './types';
|
|
2
|
+
declare const _default: PluginLintConfig;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default:
|
|
1
|
+
import type { PluginLintConfig } from './types';
|
|
2
|
+
declare const _default: PluginLintConfig;
|
|
3
3
|
export default _default;
|