From 0e692eb8d0a49e38112c4df0045880b8454b321b Mon Sep 17 00:00:00 2001 From: nscuro Date: Thu, 8 Oct 2026 18:42:48 +0200 Subject: [PATCH] Make vale lint output more helpful Shows lint errors (i.e. what MUST be fixed) grouped at the bottom, making it easier to discover what needs doing. Signed-off-by: nscuro --- .vale/output.tmpl | 48 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/.vale/output.tmpl b/.vale/output.tmpl index 34212a5e..e9fd7e42 100644 --- a/.vale/output.tmpl +++ b/.vale/output.tmpl @@ -1,16 +1,40 @@ +{{- $errors := list -}} +{{- $warnings := list -}} +{{- $suggestions := list -}} {{- range .Files -}} {{- $path := .Path -}} -{{- if .Alerts }} -{{ $path }} -{{ range .Alerts -}} -{{- if eq .Severity "error" }} error {{ end -}} -{{- if eq .Severity "warning" }} warn {{ end -}} -{{- if eq .Severity "suggestion" }} sugg {{ end -}} -{{ printf "%s:%d:%d [%s] %s" $path .Line (index .Span 0) .Check .Message }} -{{ end }} +{{- range .Alerts -}} +{{- $line := printf " %s:%d:%d [%s] %s" $path .Line (index .Span 0) .Check .Message -}} +{{- if eq .Severity "error" -}}{{- $errors = append $errors $line -}} +{{- else if eq .Severity "warning" -}}{{- $warnings = append $warnings $line -}} +{{- else -}}{{- $suggestions = append $suggestions $line -}} {{- end -}} -{{- end }} -{{ .LintedTotal }} file(s) linted. +{{- end -}} +{{- end -}} + +{{- with $suggestions }} +SUGGESTIONS ({{ len . }}). Optional. +{{ join "\n" . }} +{{ end -}} -Suppress a rule inline: ... -Scope a rule by path: edit .vale.ini (see the [docs/tutorials/*.md] block) \ No newline at end of file +{{- with $warnings }} +WARNINGS ({{ len . }}). Should fix: in new files, and in lines you added or changed. +{{ join "\n" . }} +{{ end -}} + +{{- with $errors }} +ERRORS ({{ len . }}). Must fix: the lint fails until these are resolved. +{{ join "\n" . }} +{{ end }} +{{- if or $errors $warnings }} +Fix the text first. Suppress a rule only for a confirmed false positive: + inline: ... + by path: edit .vale.ini (see the [docs/tutorials/*.md] block) +{{ end }} +{{ if $errors -}} +FAILED: {{ len $errors }} error(s) must be fixed, {{ len $warnings }} warning(s) should be fixed. {{ .LintedTotal }} file(s) linted. +{{- else if $warnings -}} +PASSED with {{ len $warnings }} warning(s) that should be fixed. {{ .LintedTotal }} file(s) linted. +{{- else -}} +PASSED: no errors or warnings. {{ .LintedTotal }} file(s) linted. +{{- end }}