pint.error --no-color lint rules
! stdout .
cmp stderr stderr.txt

-- stderr.txt --
level=info msg="Loading configuration file" path=.pint.hcl
rules/0001.yml:1-2 Bug: url annotation is required (alerts/annotation)
 1 | - alert: Always
 2 |   expr: up

rules/0001.yml:1-2 Warning: severity label is required (rule/label)
 1 | - alert: Always
 2 |   expr: up

rules/0001.yml:2 Warning: alert query doesn't have any condition, it will always fire if the metric exists (alerts/comparison)
 2 |   expr: up

rules/0001.yml:9-10 Bug: url annotation is required (alerts/annotation)
  9 | - alert: ServiceIsDown
 10 |   expr: up == 0

rules/0001.yml:9-10 Warning: severity label is required (rule/label)
  9 | - alert: ServiceIsDown
 10 |   expr: up == 0

rules/0001.yml:14 Warning: severity label value must match "^critical|warning|info$" (rule/label)
 14 |     severity: bad

rules/0001.yml:16 Bug: url annotation value must match "^https://wiki.example.com/page/(.+).html$" (alerts/annotation)
 16 |     url: bad

rules/0002.yml:5 Fatal: template parse error: undefined variable "$label" (alerts/template)
 5 |     summary: 'Instance {{ $label.instance }} down'

rules/0002.yml:6 Fatal: template parse error: undefined variable "$valuexx" (alerts/template)
 6 |     func: '{{ $valuexx | xxx }}'

rules/0002.yml:9 Fatal: template parse error: undefined variable "$label" (alerts/template)
 9 |     summary: 'Instance {{ $label.instance }} down'

rules/0002.yml:10 Fatal: template parse error: function "xxx" not defined (alerts/template)
 10 |     func: '{{ $value | xxx }}'

rules/0002.yml:11 Bug: using $value in labels will generate a new alert on every value change, move it to annotations (alerts/template)
 11 |     bar: 'Some {{$value}} value'

rules/0002.yml:12 Bug: using .Value in labels will generate a new alert on every value change, move it to annotations (alerts/template)
 12 |     val: '{{ .Value|humanizeDuration }}'

level=info msg="Problems found" Bug=5 Fatal=4 Warning=4
level=fatal msg="Fatal error" error="found 2 problem(s) with severity Bug or higher"
-- rules/0001.yml --
- alert: Always
  expr: up
- alert: AlwaysIgnored
  expr: up # pint disable alerts/comparison
  labels:
    severity: warning
  annotations:
    url: "https://wiki.example.com/page/ServiceIsDown.html"
- alert: ServiceIsDown
  expr: up == 0
- alert: ServiceIsDown
  expr: up == 0
  labels:
    severity: bad
  annotations:
    url: bad
- alert: ServiceIsDown
  expr: up == 0
  labels:
    severity: warning
  annotations:
    url: "https://wiki.example.com/page/ServiceIsDown.html"

-- rules/0002.yml --
- alert: Foo Is Down
  expr: up{job="foo"} == 0
  annotations:
    url: "https://wiki.example.com/page/ServiceIsDown.html"
    summary: 'Instance {{ $label.instance }} down'
    func: '{{ $valuexx | xxx }}'
  labels:
    severity: warning
    summary: 'Instance {{ $label.instance }} down'
    func: '{{ $value | xxx }}'
    bar: 'Some {{$value}} value'
    val: '{{ .Value|humanizeDuration }}'
    ignore: '$value is not a variable'

-- .pint.hcl --
parser {
  relaxed = ["rules/.*"]
}
rule {
    annotation "url" {
        severity = "bug"
        value = "https://wiki.example.com/page/(.+).html"
        required = true
    }
    label "severity" {
        value = "critical|warning|info"
        required = true
    }
}
