(
{ plugin, slug, weight }: CategoryRef,
plugins: ScoredReport['plugins'],
)
| 59 | } |
| 60 | |
| 61 | export function getSortableGroupByRef( |
| 62 | { plugin, slug, weight }: CategoryRef, |
| 63 | plugins: ScoredReport['plugins'], |
| 64 | ): SortableGroup { |
| 65 | const groupPlugin = plugins.find(p => p.slug === plugin); |
| 66 | if (!groupPlugin) { |
| 67 | throwIsNotPresentError(`Plugin ${plugin}`, 'report'); |
| 68 | } |
| 69 | |
| 70 | const group = groupPlugin.groups?.find( |
| 71 | ({ slug: groupSlug }) => groupSlug === slug, |
| 72 | ); |
| 73 | if (!group) { |
| 74 | throwIsNotPresentError(`Group ${slug}`, groupPlugin.slug); |
| 75 | } |
| 76 | |
| 77 | const sortedAudits = getSortedGroupAudits(group, groupPlugin.slug, plugins); |
| 78 | const sortedAuditRefs = group.refs.toSorted((a, b) => { |
| 79 | const aIndex = sortedAudits.findIndex(ref => ref.slug === a.slug); |
| 80 | const bIndex = sortedAudits.findIndex(ref => ref.slug === b.slug); |
| 81 | return aIndex - bIndex; |
| 82 | }); |
| 83 | |
| 84 | return { |
| 85 | ...group, |
| 86 | refs: sortedAuditRefs, |
| 87 | plugin, |
| 88 | weight, |
| 89 | }; |
| 90 | } |
| 91 | |
| 92 | export function sortReport(report: ScoredReport): ScoredReport { |
| 93 | const { categories, plugins } = report; |
no test coverage detected