yamllint
yamllint copied to clipboard
Suggestion: Option to output violating line
We're using yamllint to lint yaml which is generated from a template (Kubernetes Helm charts, specifically). For this reason, we typically don't have the final yaml rendered anywhere, and since some templates will expand to multiple lines, getting 10:47 error too many spaces inside braces (braces)
means a bit of detective work to figure out what that line maps to in the actual template.
It would be really helpful with a --verbose
flag or similar to get the line as read by the linter written beside the error message. Or even something like grep's -C
context flags, to get the surrounding lines.
I had a look through the code, and from my understand it's currently dealing with lines or tokens? This would seem to make it a bit more complicated, than just shoving the line content into the LintProblem
class - and maybe that wouldn't be a great approach anyway?
If this seems like something you'd accept and the approach seems valid, I could spend some time implementing it.
This seems a good idea. Such a new option would need to be consistent, work with all linting errors, and integrate well with existing output formats (-f
option). You're right: LintProblem
s are output per lines, tokens, or syntax error.
In my opinion, implementing this would be hard because of these last 2 reasons. But if you have a clean and consistent solution, I'll happily review it.
PS: Some tools (like code editors) use the -f parsable
output to report problematic lines directly in the file. In your Kubernetes Helm charts use-case, maybe another approach would be to write YAML to a temporary file?
Is it possible to set the equivalent of -f parsable
in the configuration? or must that be passed as an argument?
Nope, found the answer here: https://github.com/adrienverge/yamllint/issues/266