Welcome to mirror list, hosted at ThFree Co, Russian Federation.

vale-json.tmpl « .vale « doc - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7969cb704a01aad2d5e6c239b4e6994652391d65 (plain)
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
{{- /* Modify Vale's output https://docs.errata.ai/vale/cli#--output */ -}}

{{- $fileIndexes := len .Files -}}
{{- $fileIndexes = sub $fileIndexes 1 -}}

[
  {{- /* Range over the linted files */ -}}
  {{- range $idx1, $a := .Files -}}
    {{- $path := .Path -}}

    {{/* Range over the file's alerts */}}
    {{- range $idx2, $b := .Alerts -}}
      {{- $error := "info" -}}
      {{- if eq .Severity "error" -}}
        {{- $error = "blocker" -}}
      {{- else if eq .Severity "warning" -}}
        {{- $error = "major" -}}
      {{- end}}

      {{- /* Variables setup */ -}}
      {{- $loc := printf "%d" .Line -}}
      {{- $message := printf "%s" .Message -}}
      {{- if $idx2 -}},{{- end -}}

  {{/* Output */}}
  {
    "description": "{{ $message }}",
    "fingerprint": "{{ $path }}-{{ $loc }}",
    "severity": "{{ $error }}",
    "location": {
      "path": "{{ $path }}",
      "lines": {
        "begin": {{ $loc }}
      }
    }
  }
    {{- end}}{{- if (lt $idx1 $fileIndexes) -}},{{- end -}}
  {{- end}}
]