diff --git a/src/formatter/markdown.ts b/src/formatter/markdown.ts index e94b8d67c..f811af2d8 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 beb8e8261..561cbc77f 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 db0985595..58767fd53 100644 Binary files a/test/lib/formatter/snapshots/markdown.ts.snap and b/test/lib/formatter/snapshots/markdown.ts.snap differ