-
Notifications
You must be signed in to change notification settings - Fork 9
/
vale-json.tmpl
58 lines (46 loc) · 1.14 KB
/
vale-json.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{{- /* Modify Vale's output https://docs.errata.ai/vale/cli#--output */ -}}
{{- /* Keep track of our various counts */ -}}
{{- $e := 0 -}}
{{- $w := 0 -}}
{{- $s := 0 -}}
{{- $f := 0 -}}
{{- /* Range over the linted files */ -}}
{{- range .Files}}
{{- $f = add1 $f -}}
{{- $path := .Path -}}
{{- /* Range over the file's alerts */ -}}
[
{{- range $idx, $a := .Alerts -}}
{{- $error := "" -}}
{{- if eq .Severity "error" -}}
{{- $error = .Severity -}}
{{- $e = add1 $e -}}
{{- else if eq .Severity "warning" -}}
{{- $error = .Severity -}}
{{- $w = add1 $w -}}
{{- else -}}
{{- $error = .Severity -}}
{{- $s = add1 $s -}}
{{- end}}
{{- /* Variables setup */ -}}
{{- $path = $path -}}
{{- $loc := printf "%d" .Line -}}
{{- $check := printf "%s" .Check -}}
{{- $message := printf "%s" .Message -}}
{{- $link := printf "%s" .Link -}}
{{- if $idx -}},{{- end -}}
{{- /* Output */ -}}
{
"description": "{{ $message }}",
"fingerprint": "{{ $path }}-{{ $loc }}",
"severity": "{{ $error }}",
"location": {
"path": "{{ $path }}",
"lines": {
"begin": {{ $loc }}
}
}
}
{{end -}}
{{end -}}
]