From ec8af44c1d82cf9fcc530aa8e0aa80bf76f0d133 Mon Sep 17 00:00:00 2001 From: Max Reichmann Date: Tue, 3 Dec 2024 12:04:52 +0100 Subject: [PATCH] feat: Add ruleId to Markdown format output --- src/formatter/markdown.ts | 11 +++-- test/lib/formatter/snapshots/markdown.ts.md | 44 +++++++++--------- test/lib/formatter/snapshots/markdown.ts.snap | Bin 517 -> 534 bytes 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/formatter/markdown.ts b/src/formatter/markdown.ts index e94b8d67..f811af2d 100644 --- a/src/formatter/markdown.ts +++ b/src/formatter/markdown.ts @@ -21,11 +21,11 @@ export class Markdown { // Add the file path as a section header findings += `### ${filePath}\n\n`; if (showDetails === true) { - findings += `| Severity | Line | Message | Details |\n`; - findings += `|----------|------|---------|---------|\n`; + findings += `| Severity | Rule | Location | Message | Details |\n`; + findings += `|----------|------|----------|---------|---------|\n`; } else { - findings += `| Severity | Line | Message |\n`; - findings += `|----------|------|---------|\n`; + findings += `| Severity | Rule | Location | Message |\n`; + findings += `|----------|------|----------|---------|\n`; } // Sort messages by severity (sorting order: fatal-errors, errors, warnings) @@ -50,6 +50,7 @@ export class Markdown { messages.forEach((msg) => { const severity = this.formatSeverity(msg.severity, msg.fatal); const location = this.formatLocation(msg.line, msg.column); + const rule = msg.ruleId ?? "n/a"; let details; if (showDetails) { details = ` ${this.formatMessageDetails(msg)} |`; @@ -57,7 +58,7 @@ export class Markdown { details = ""; } - findings += `| ${severity} | \`${location}\` | ${msg.message} |${details}\n`; + findings += `| ${severity} | ${rule} | \`${location}\` | ${msg.message} |${details}\n`; }); findings += "\n"; diff --git a/test/lib/formatter/snapshots/markdown.ts.md b/test/lib/formatter/snapshots/markdown.ts.md index beb8e826..561cbc77 100644 --- a/test/lib/formatter/snapshots/markdown.ts.md +++ b/test/lib/formatter/snapshots/markdown.ts.md @@ -17,20 +17,20 @@ Generated by [AVA](https://avajs.dev). ## Findings␊ ### webapp/Component.js␊ ␊ - | Severity | Line | Message |␊ - |----------|------|---------|␊ - | Error | \`1:1\` | Error message |␊ - | Warning | \`2:2\` | Warning message |␊ + | Severity | Rule | Location | Message |␊ + |----------|------|----------|---------|␊ + | Error | rule1 | \`1:1\` | Error message |␊ + | Warning | rule2 | \`2:2\` | Warning message |␊ ␊ ### webapp/Main.controller.js␊ ␊ - | Severity | Line | Message |␊ - |----------|------|---------|␊ - | Fatal Error | \`3:6\` | Another error message |␊ - | Fatal Error | \`12:3\` | Another error message |␊ - | Error | \`11:2\` | Another error message |␊ - | Error | \`11:3\` | Another error message |␊ - | Warning | \`12:3\` | Another error message |␊ + | Severity | Rule | Location | Message |␊ + |----------|------|----------|---------|␊ + | Fatal Error | rule3 | \`3:6\` | Another error message |␊ + | Fatal Error | rule3 | \`12:3\` | Another error message |␊ + | Error | rule3 | \`11:2\` | Another error message |␊ + | Error | rule3 | \`11:3\` | Another error message |␊ + | Warning | rule3 | \`12:3\` | Another error message |␊ ␊ **Note:** Use \`ui5lint --details\` to show more information about the findings.␊ ` @@ -48,20 +48,20 @@ Generated by [AVA](https://avajs.dev). ## Findings␊ ### webapp/Component.js␊ ␊ - | Severity | Line | Message | Details |␊ - |----------|------|---------|---------|␊ - | Error | \`1:1\` | Error message | Message details |␊ - | Warning | \`2:2\` | Warning message | Message details |␊ + | Severity | Rule | Location | Message | Details |␊ + |----------|------|----------|---------|---------|␊ + | Error | rule1 | \`1:1\` | Error message | Message details |␊ + | Warning | rule2 | \`2:2\` | Warning message | Message details |␊ ␊ ### webapp/Main.controller.js␊ ␊ - | Severity | Line | Message | Details |␊ - |----------|------|---------|---------|␊ - | Fatal Error | \`3:6\` | Another error message | Message details |␊ - | Fatal Error | \`12:3\` | Another error message | Message details |␊ - | Error | \`11:2\` | Another error message | Message details |␊ - | Error | \`11:3\` | Another error message | Message details |␊ - | Warning | \`12:3\` | Another error message | Message details |␊ + | Severity | Rule | Location | Message | Details |␊ + |----------|------|----------|---------|---------|␊ + | Fatal Error | rule3 | \`3:6\` | Another error message | Message details |␊ + | Fatal Error | rule3 | \`12:3\` | Another error message | Message details |␊ + | Error | rule3 | \`11:2\` | Another error message | Message details |␊ + | Error | rule3 | \`11:3\` | Another error message | Message details |␊ + | Warning | rule3 | \`12:3\` | Another error message | Message details |␊ ␊ ` diff --git a/test/lib/formatter/snapshots/markdown.ts.snap b/test/lib/formatter/snapshots/markdown.ts.snap index db098559559f0c07172d6311be8c58058c43f51e..58767fd53e5ce6e841c9076384e5f51fe5923c22 100644 GIT binary patch literal 534 zcmV+x0_puhRzV|=l(APi%q+;O>5gdr>Y914|`A{GPz7Bt~`{`95J za;-?Y?q|!G#~FPgBisc%P76u!IMP$@gjVo4CTsbO;F<5Nm#;jkubz3lE=PceDI`Vk z7)QfsjO+bu(-QBOCRW<^!n zGrmyT&B-hyulV{!T@(-dzc0L55-sy+R&vWJ)!6Se8Vkb{?PwT=7+J!&5CbWcL#LCF z<3idooQ9q21u|_2LZ#Yd%kcR`7Y=StNLTl<%QmQ7Ro9^Mse;P8_J4y4R-PJMwO#O8 zADC>8YXVeF{og|DPZQV)yV^W<1F^PMQ#9|~r12!p@vZyUD+13?^cu?>6n+?OL%8?m Yb_RP}4EELx_9_grp9}wZBryj70IeJZ5C8xG literal 517 zcmV+g0{ZT*kw{b zCqwNSYvzThk~fHN-~)>IJpOp_8)jWzP^^q>0$iHyLh4v&&jT?Ys>LZ`e76w z{=T4=4p$TICT;1uadB-HL>QhLrZ@~Sc7(}7jWVSfy=W&(ds6q_CF~7#e--~fnr$y6 z8YkTklExOhV$)i@_sP4X)%3U4bX=U83YlLBc{|<&