brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: yamllint -f parsable prints one line per problem for scripts and editors

Yaml
~/tips/tip-yamllint-parsable-format

yamllint -f parsable config.yaml

Print yamllint results as one machine-readable line per problem.

A Compose or Home Assistant file with one wrong space can cost me a while. yamllint finds those, and the default output is made for humans.

Run it on a file and you get a grouped report with line and column. For scripts, CI or an editor that wants file:line:col, switch the format:

yamllint -f parsable config.yaml

Each problem is one line, for example y.yaml:2:5: [error] too many spaces after colon (colons). The level is error or warning, and the rule name is at the end, so you can look it up or turn it off.

The exit code is 1 when there is an error. Warnings alone don’t fail the run; add -s (--strict) to make them fail too.

A caveat: yamllint checks style as well as syntax, so a file that loads fine can still produce warnings, such as a missing --- at the start.

Further reading: yamllint documentation

Going deeper: Guide: replace a cron job with a systemd timer, and see when it runs next

More Yaml tips yamllint -d relaxed docker-compose.yml iif(condition, if_true, if_false, if_none) Sensor is available Today_at() makes time-of-day checks in Home Assistant templates easy actions: All Yaml tips (10) All topics

Link