Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/core/src/lib/implementation/read-rc-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
type CoreConfig,
SUPPORTED_CONFIG_FILE_FORMATS,
coreConfigSchema,
validate,
} from '@code-pushup/models';
import { fileExists, importModule, parseSchema } from '@code-pushup/utils';
import { fileExists, importModule } from '@code-pushup/utils';

export class ConfigPathError extends Error {
constructor(configPath: string) {
Expand All @@ -31,7 +32,7 @@ export async function readRcByPath(
format: 'esm',
});

return parseSchema(coreConfigSchema, cfg, {
return validate(coreConfigSchema, cfg, {
schemaType: 'core config',
sourcePath: filepath,
});
Expand Down
5 changes: 3 additions & 2 deletions packages/models/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
},
"type": "module",
"dependencies": {
"zod": "^4.0.5",
"vscode-material-icons": "^0.1.0"
"ansis": "^3.3.2",
"vscode-material-icons": "^0.1.0",
"zod": "^4.0.5"
},
"files": [
"src",
Expand Down
4 changes: 4 additions & 0 deletions packages/models/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export {
type MaterialIcon,
} from './lib/implementation/schemas.js';
export { exists } from './lib/implementation/utils.js';
export {
SchemaValidationError,
validate,
} from './lib/implementation/validate.js';
export {
issueSchema,
issueSeveritySchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class SchemaValidationError extends Error {
}
}

export function parseSchema<T extends z.ZodTypeAny>(
export function validate<T extends z.ZodTypeAny>(
Comment thread
hanna-skryl marked this conversation as resolved.
Outdated
schema: T,
data: z.input<T>,
{ schemaType, sourcePath }: SchemaValidationContext,
Expand Down
7 changes: 3 additions & 4 deletions packages/plugin-eslint/src/lib/eslint-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createRequire } from 'node:module';
import type { PluginConfig } from '@code-pushup/models';
import { parseSchema } from '@code-pushup/utils';
import { type PluginConfig, validate } from '@code-pushup/models';
import {
type ESLintPluginConfig,
type ESLintPluginOptions,
Expand Down Expand Up @@ -36,7 +35,7 @@ export async function eslintPlugin(
config: ESLintPluginConfig,
options?: ESLintPluginOptions,
): Promise<PluginConfig> {
const targets = parseSchema(eslintPluginConfigSchema, config, {
const targets = validate(eslintPluginConfigSchema, config, {
schemaType: 'ESLint plugin config',
});

Expand All @@ -45,7 +44,7 @@ export async function eslintPlugin(
artifacts,
scoreTargets,
} = options
? parseSchema(eslintPluginOptionsSchema, options, {
? validate(eslintPluginOptionsSchema, options, {
schemaType: 'ESLint plugin options',
})
: {};
Expand Down
1 change: 0 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"multi-progress-bars": "^5.0.3",
"semver": "^7.6.0",
"simple-git": "^3.20.0",
"zod": "^4.0.5",
"ora": "^9.0.0"
},
"files": [
Expand Down
1 change: 0 additions & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,3 @@ export type {
Prettify,
WithRequired,
} from './lib/types.js';
export { parseSchema, SchemaValidationError } from './lib/zod-validation.js';