Skip to content

Commit a5b9817

Browse files
illiaRedocJLekawa
andauthored
fix: remove mutation of rootRedoclyConfigSchema constant (#2496)
Co-authored-by: Jacek Łękawa <[email protected]>
1 parent 48607a8 commit a5b9817

File tree

3 files changed

+293
-285
lines changed

3 files changed

+293
-285
lines changed

packages/core/src/lint.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ import type {
3333
import type { CollectFn } from './utils/types.js';
3434
import type { JSONSchema } from 'json-schema-to-ts';
3535

36-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
37-
// @ts-ignore FIXME: remove this once we remove `theme` from the schema
38-
delete rootRedoclyConfigSchema.properties.theme;
36+
// FIXME: remove this once we remove `theme` from the schema
37+
const { theme: _, ...propertiesWithoutTheme } = rootRedoclyConfigSchema.properties;
38+
const redoclyConfigSchemaWithoutTheme = {
39+
...rootRedoclyConfigSchema,
40+
properties: propertiesWithoutTheme,
41+
};
3942

4043
export async function lint(opts: {
4144
ref: string;
@@ -150,7 +153,7 @@ export async function lintConfig(opts: {
150153
};
151154

152155
const types = normalizeTypes(
153-
opts.externalConfigTypes || createConfigTypes(rootRedoclyConfigSchema, config)
156+
opts.externalConfigTypes || createConfigTypes(redoclyConfigSchemaWithoutTheme, config)
154157
);
155158

156159
const rules: (RuleInstanceConfig & {

packages/core/src/types/redocly-yaml.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,14 @@ const CoreConfigTypes: Record<string, NodeType> = {
476476
AssertionDefinitionAssertions,
477477
};
478478

479-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
480-
// @ts-ignore FIXME: remove this once we remove `theme` from the schema
481-
delete rootRedoclyConfigSchema.properties.theme;
479+
// FIXME: remove this once we remove `theme` from the schema
480+
const { theme: _, ...propertiesWithoutTheme } = rootRedoclyConfigSchema.properties;
481+
const redoclyConfigSchemaWithoutTheme = {
482+
...rootRedoclyConfigSchema,
483+
properties: propertiesWithoutTheme,
484+
};
482485

483-
export const ConfigTypes: Record<string, NodeType> = createConfigTypes(rootRedoclyConfigSchema);
486+
export const ConfigTypes: Record<string, NodeType> = createConfigTypes(
487+
redoclyConfigSchemaWithoutTheme
488+
);
484489
export const NormalizedConfigTypes = normalizeTypes(ConfigTypes);

0 commit comments

Comments
 (0)