@cms-lab/reporter 1.2.4 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +77 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -243,6 +243,48 @@ function renderHtmlReport(result, options = {}) {
243
243
  .chip .n { color: var(--muted); }
244
244
  .chip.active { background: var(--ink); color: #f6f5ef; border-color: var(--ink); }
245
245
  .chip.active .n { color: #b8b7ad; }
246
+ .repeated {
247
+ padding: 16px 20px;
248
+ border-top: 1px solid var(--border);
249
+ border-bottom: 1px solid var(--border);
250
+ background: var(--surface);
251
+ }
252
+ .repeated h2 {
253
+ font-size: 13px;
254
+ margin-bottom: 10px;
255
+ font-family: var(--mono);
256
+ letter-spacing: 0;
257
+ }
258
+ .repeated-list {
259
+ display: grid;
260
+ gap: 8px;
261
+ margin: 0;
262
+ padding: 0;
263
+ list-style: none;
264
+ }
265
+ .repeated-list li {
266
+ display: grid;
267
+ grid-template-columns: minmax(0, 1fr) auto;
268
+ gap: 12px;
269
+ align-items: start;
270
+ font-size: 13px;
271
+ }
272
+ .repeated-main { min-width: 0; }
273
+ .repeated-title {
274
+ font-family: var(--mono);
275
+ color: var(--ink);
276
+ overflow-wrap: anywhere;
277
+ }
278
+ .repeated-examples {
279
+ color: var(--muted);
280
+ margin-top: 2px;
281
+ overflow-wrap: anywhere;
282
+ }
283
+ .repeated-count {
284
+ font-family: var(--mono);
285
+ color: var(--muted);
286
+ white-space: nowrap;
287
+ }
246
288
  .group-header {
247
289
  padding: 10px 20px;
248
290
  background: var(--surface-2);
@@ -430,6 +472,8 @@ function renderHtmlReport(result, options = {}) {
430
472
  <div class="stat"><div class="k">Single types</div><div class="v">${documentStats.singleTypes}</div><div class="sub">${documentStats.singleTypes} ${escapeHtml(plural(documentStats.singleTypes, "single type"))}</div></div>` : ""}
431
473
  </div>
432
474
 
475
+ ${repeatedDiagnosticGroups(result)}
476
+
433
477
  <div class="report-toolbar" aria-label="Diagnostic filters">
434
478
  <button class="chip active" type="button" data-filter-kind="all" data-filter-value="all">All <span class="n">${diagnostics.length}</span></button>
435
479
  <button class="chip" type="button" data-filter-kind="severity" data-filter-value="error">Errors <span class="n">${result.summary.errors}</span></button>
@@ -517,11 +561,40 @@ function statusLabel(result) {
517
561
  }
518
562
  return "no errors";
519
563
  }
564
+ function repeatedDiagnosticGroups(result) {
565
+ const groups = (result.diagnosticGroups ?? []).filter(
566
+ (group) => group.count > 1
567
+ );
568
+ if (groups.length === 0) {
569
+ return "";
570
+ }
571
+ return `<section class="repeated" aria-label="Repeated findings">
572
+ <h2>Repeated findings</h2>
573
+ <ul class="repeated-list">
574
+ ${groups.map(
575
+ (group) => `<li>
576
+ <div class="repeated-main">
577
+ <div class="repeated-title">${escapeHtml(group.label)} \xB7 ${escapeHtml(group.code)}</div>
578
+ ${group.examples.length > 0 ? `<div class="repeated-examples">${escapeHtml(group.examples.join(", "))}</div>` : ""}
579
+ </div>
580
+ <div class="repeated-count">x${group.count}</div>
581
+ </li>`
582
+ ).join("")}
583
+ </ul>
584
+ </section>`;
585
+ }
520
586
  function plural(value, singular) {
521
587
  return value === 1 ? singular : `${singular}s`;
522
588
  }
523
589
  function groupDiagnostics(diagnostics) {
524
- const groupOrder = ["routes", "fields", "seo", "a11y", "other"];
590
+ const groupOrder = [
591
+ "routes",
592
+ "fields",
593
+ "relationships",
594
+ "seo",
595
+ "a11y",
596
+ "other"
597
+ ];
525
598
  const groups = /* @__PURE__ */ new Map();
526
599
  for (const diagnostic of diagnostics) {
527
600
  const group = groupForDiagnostic(diagnostic);
@@ -536,6 +609,9 @@ function groupForDiagnostic(diagnostic) {
536
609
  if (diagnostic.code.startsWith("CMS-FIELD")) {
537
610
  return "fields";
538
611
  }
612
+ if (diagnostic.code.startsWith("CMS-RELATIONSHIP")) {
613
+ return "relationships";
614
+ }
539
615
  if (diagnostic.code.startsWith("SEO-")) {
540
616
  return "seo";
541
617
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cms-lab/reporter",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "type": "module",
5
5
  "description": "HTML report rendering for cms-lab.",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@cms-lab/core": "1.2.4"
38
+ "@cms-lab/core": "1.2.6"
39
39
  },
40
40
  "author": "Afaq Rashid",
41
41
  "scripts": {