(rule: RuleData)
| 4 | import type { RuleData } from './parse.js'; |
| 5 | |
| 6 | export 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 | } |
no test coverage detected