|
1 | 1 | import { z } from 'zod';
|
2 | 2 | import { toArray } from '@code-pushup/utils';
|
3 | 3 |
|
4 |
| -const patternsSchema = z.union([z.string(), z.array(z.string()).min(1)], { |
5 |
| - description: |
| 4 | +const patternsSchema = z |
| 5 | + .union([z.string(), z.array(z.string()).min(1)]) |
| 6 | + .describe( |
6 | 7 | 'Lint target files. May contain file paths, directory paths or glob patterns',
|
7 |
| -}); |
| 8 | + ); |
8 | 9 |
|
9 |
| -const eslintrcSchema = z.string({ description: 'Path to ESLint config file' }); |
| 10 | +const eslintrcSchema = z.string().describe('Path to ESLint config file'); |
10 | 11 |
|
11 | 12 | const eslintTargetObjectSchema = z.object({
|
12 | 13 | eslintrc: eslintrcSchema.optional(),
|
@@ -34,30 +35,26 @@ export type ESLintPluginRunnerConfig = {
|
34 | 35 | slugs: string[];
|
35 | 36 | };
|
36 | 37 |
|
37 |
| -const customGroupRulesSchema = z.union( |
38 |
| - [ |
| 38 | +const customGroupRulesSchema = z |
| 39 | + .union([ |
39 | 40 | z
|
40 | 41 | .array(z.string())
|
41 | 42 | .min(1, 'Custom group rules must contain at least 1 element'),
|
42 |
| - z.record(z.string(), z.number()).refine( |
43 |
| - schema => Object.keys(schema).length > 0, |
44 |
| - () => ({ |
45 |
| - code: 'too_small', |
46 |
| - message: 'Custom group rules must contain at least 1 element', |
| 43 | + z |
| 44 | + .record(z.string(), z.number()) |
| 45 | + .refine(schema => Object.keys(schema).length > 0, { |
| 46 | + error: 'Custom group rules must contain at least 1 element', |
47 | 47 | }),
|
48 |
| - ), |
49 |
| - ], |
50 |
| - { |
51 |
| - description: |
52 |
| - 'Array of rule IDs with equal weights or object mapping rule IDs to specific weights', |
53 |
| - }, |
54 |
| -); |
| 48 | + ]) |
| 49 | + .describe( |
| 50 | + 'Array of rule IDs with equal weights or object mapping rule IDs to specific weights', |
| 51 | + ); |
55 | 52 |
|
56 | 53 | const customGroupSchema = z.object({
|
57 |
| - slug: z.string({ description: 'Unique group identifier' }), |
58 |
| - title: z.string({ description: 'Group display title' }), |
59 |
| - description: z.string({ description: 'Group metadata' }).optional(), |
60 |
| - docsUrl: z.string({ description: 'Group documentation site' }).optional(), |
| 54 | + slug: z.string().describe('Unique group identifier'), |
| 55 | + title: z.string().describe('Group display title'), |
| 56 | + description: z.string().describe('Group metadata').optional(), |
| 57 | + docsUrl: z.string().describe('Group documentation site').optional(), |
61 | 58 | rules: customGroupRulesSchema,
|
62 | 59 | });
|
63 | 60 | export type CustomGroup = z.infer<typeof customGroupSchema>;
|
|
0 commit comments