Skip to content

Commit a20ad4a

Browse files
authored
Merge pull request #73233 from rohennes/vale-bot-template
Adding vale template for OCP valebot output
2 parents 24fde85 + 248c4e3 commit a20ad4a

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{{- /* Modify Vale's output https://docs.errata.ai/vale/cli#--output */ -}}
2+
3+
{{- /* Keep track of our various counts */ -}}
4+
5+
{{- $e := 0 -}}
6+
{{- $w := 0 -}}
7+
{{- $s := 0 -}}
8+
9+
{{- /* Range over the linted files */ -}}
10+
11+
[
12+
{{- range $jdx, $file := .Files -}}
13+
14+
{{- $path := .Path -}}
15+
16+
{{- /* Range over the file's alerts */ -}}
17+
18+
{{- if $jdx -}},{{- end -}}
19+
{{- range $idx, $a := .Alerts -}}
20+
21+
{{- $error := "" -}}
22+
{{- if eq .Severity "error" -}}
23+
{{- $error = "error" -}}
24+
{{- $e = add1 $e -}}
25+
{{- else if eq .Severity "warning" -}}
26+
{{- $error = "warning" -}}
27+
{{- $w = add1 $w -}}
28+
{{- else -}}
29+
{{- $error = "suggestion" -}}
30+
{{- $s = add1 $s -}}
31+
{{- end}}
32+
33+
{{- /* Variables setup */ -}}
34+
35+
{{- $loc := printf "%d" .Line -}}
36+
{{- $check := printf "%s" .Check -}}
37+
{{- $message := printf "%s" .Message -}}
38+
{{- if $idx -}},{{- end -}}
39+
40+
{{- /* Output */ -}}
41+
42+
{
43+
"body": "🤖 **[{{ $error }}] {{$check}}**: {{ $message }}",
44+
"path": "{{ $path }}",
45+
"line": {{ $loc }}
46+
}
47+
{{end -}}
48+
{{end -}}
49+
]

0 commit comments

Comments
 (0)