MCPcopy Create free account
hub / github.com/code-pushup/cli / ruleToAudit

Function ruleToAudit

packages/plugin-eslint/src/lib/meta/transform.ts:6–28  ·  view source on GitHub ↗
(rule: RuleData)

Source from the content-addressed store, hash-verified

4import type { RuleData } from './parse.js';
5
6export function ruleToAudit(rule: RuleData): Audit {
7 const name = rule.id.split('/').at(-1) ?? rule.id;
8 const plugin =
9 name === rule.id ? null : rule.id.slice(0, rule.id.lastIndexOf('/'));
10 const pluginContext = plugin ? `, from _${plugin}_ plugin` : '';
11
12 const lines: string[] = [
13 `ESLint rule **${name}**${pluginContext}.`,
14 ...(rule.options?.length ? ['Custom options:'] : []),
15 ...(rule.options?.map(option =>
16 ['```json', JSON.stringify(option, null, 2), '```'].join('\n'),
17 ) ?? []),
18 ];
19
20 return {
21 slug: ruleToSlug(rule),
22 title: truncateTitle(rule.meta.docs?.description ?? name),
23 description: truncateDescription(lines.join('\n\n')),
24 ...(rule.meta.docs?.url && {
25 docsUrl: rule.meta.docs.url,
26 }),
27 };
28}

Callers 1

Calls 3

truncateTitleFunction · 0.90
truncateDescriptionFunction · 0.90
ruleToSlugFunction · 0.85

Tested by

no test coverage detected