Skip to content

Commit fe80d80

Browse files
authored
fix(cli): Convert severity to GitHub workflow commands format (#337)
1 parent b348303 commit fe80d80

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

cmd/rslint/cmd.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ func printDiagnostic(d rule.RuleDiagnostic, w *bufio.Writer, comparePathOptions
9797

9898
// print as [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands) format
9999
func printDiagnosticGitHub(d rule.RuleDiagnostic, w *bufio.Writer, comparePathOptions tspath.ComparePathsOptions) {
100+
var severity string
101+
switch d.Severity {
102+
case rule.SeverityError:
103+
severity = "error"
104+
case rule.SeverityWarning:
105+
severity = "warning"
106+
default:
107+
severity = "notice"
108+
}
109+
100110
diagnosticStart := d.Range.Pos()
101111
diagnosticEnd := d.Range.End()
102112

@@ -106,7 +116,7 @@ func printDiagnosticGitHub(d rule.RuleDiagnostic, w *bufio.Writer, comparePathOp
106116
filePath := tspath.ConvertToRelativePath(d.SourceFile.FileName(), comparePathOptions)
107117
output := fmt.Sprintf(
108118
"::%s file=%s,line=%d,endLine=%d,col=%d,endColumn=%d,title=%s::%s\n",
109-
d.Severity.String(),
119+
severity,
110120
escapeProperty(filePath),
111121
startLine+1,
112122
endLine+1,

packages/rslint-test-tools/tests/cli/basic.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ describe('CLI Configuration Tests', () => {
224224
},
225225
},
226226
rules: {
227+
'@typescript-eslint/no-explicit-any': 'warn',
227228
'@typescript-eslint/no-unsafe-member-access': 'error',
228229
},
229230
plugins: ['@typescript-eslint'],
@@ -253,7 +254,7 @@ describe('CLI Configuration Tests', () => {
253254

254255
expect(lines.length).toBe(2);
255256
expect(lines[0]).toBe(
256-
'::error file=test%3A%25%2C%0D%0Afile.ts,line=2,endLine=2,col=16,endColumn=19,title=@typescript-eslint/no-explicit-any::Unexpected any. Specify a different type.',
257+
'::warning file=test%3A%25%2C%0D%0Afile.ts,line=2,endLine=2,col=16,endColumn=19,title=@typescript-eslint/no-explicit-any::Unexpected any. Specify a different type.',
257258
);
258259
expect(lines[1]).toBe(
259260
'::error file=test%3A%25%2C%0D%0Afile.ts,line=3,endLine=3,col=11,endColumn=12,title=@typescript-eslint/no-unsafe-member-access::Unsafe member access .b on an `any` value.',

0 commit comments

Comments
 (0)