@code-pushup/eslint-plugin
Version:
Code PushUp plugin for detecting problems in source code using ESLint.📋
40 lines • 1.75 kB
JavaScript
import { z } from 'zod';
import { toArray } from '@code-pushup/utils';
const patternsSchema = z.union([z.string(), z.array(z.string()).min(1)], {
description: 'Lint target files. May contain file paths, directory paths or glob patterns',
});
const eslintrcSchema = z.string({ description: 'Path to ESLint config file' });
const eslintTargetObjectSchema = z.object({
eslintrc: eslintrcSchema.optional(),
patterns: patternsSchema,
});
export const eslintTargetSchema = z
.union([patternsSchema, eslintTargetObjectSchema])
.transform((target) => typeof target === 'string' || Array.isArray(target)
? { patterns: target }
: target);
export const eslintPluginConfigSchema = z
.union([eslintTargetSchema, z.array(eslintTargetSchema).min(1)])
.transform(toArray);
const customGroupRulesSchema = z.union([
z
.array(z.string())
.min(1, 'Custom group rules must contain at least 1 element'),
z.record(z.string(), z.number()).refine(schema => Object.keys(schema).length > 0, () => ({
code: 'too_small',
message: 'Custom group rules must contain at least 1 element',
})),
], {
description: 'Array of rule IDs with equal weights or object mapping rule IDs to specific weights',
});
const customGroupSchema = z.object({
slug: z.string({ description: 'Unique group identifier' }),
title: z.string({ description: 'Group display title' }),
description: z.string({ description: 'Group metadata' }).optional(),
docsUrl: z.string({ description: 'Group documentation site' }).optional(),
rules: customGroupRulesSchema,
});
export const eslintPluginOptionsSchema = z.object({
groups: z.array(customGroupSchema).optional(),
});
//# sourceMappingURL=config.js.map