aspect-build / rules_lint

Run static analysis tools with Bazel
Apache License 2.0
73 stars 39 forks source link

[Bug]: show "stylish" output #324

Closed alexeagle closed 1 month ago

alexeagle commented 1 month ago

What happened?

In https://github.com/aspect-build/rules_lint/pull/140 I changed the formatter for eslint to the "compact" format, with reasoning explained in the PR.

However the stylish output is nicer for human-readability. Other linters have the same problem to a greater extent (perhaps tflint for example). The "machine-readable" output that https://github.com/reviewdog/errorformat can parse (e.g. for the editor to make the line:column clickable) is not nearly as nice as "human-readable" output.

Version

HEAD

How to reproduce

No response

Any other information?

Proposal is to add a flag like --@aspect_rules_lint//lint:output-machine-readable which tells any linter implementation that is aware of it to produce a machine-readable output. That could be a "compact" format, or perhaps the linter produces SARIF format directly so that no futher parsing is needed.

Note, for compatibility with tools that already wrap rules_lint, we may want to have a different report filename in the machine-readable case so those tools can be conditional in how they parse the report file.

alexeagle commented 1 month ago

as another example, when Vale is run with --output=CLI it prints the diagnostic level, which users need to understand whether they configured their errors vs. warnings correctly

Screenshot 2024-07-12 at 2 18 40 PM

However currently we use --output=line with Vale to make it machine-parseable, and so we lose the severity (as well as the nice coloring)