Add support for linters
Unlike formatters, multiple linters can be executed for a single file. Linters sometimes also write back fixes to the file.
The config format has rooms for a [linters.<name>] section.
This needs to be specced-out a bit more.
See also https://github.com/reviewdog/reviewdog
I would like this to work around https://github.com/astral-sh/ruff/issues/8232 by running ruff check --fix && ruff format.
Something like this should work:
[formatter.ruff]
command = "sh"
options = ["-c", "ruff check \"$@\" && ruff format \"$@\"", "--"]
includes = ["*.py", "*.pyi"]
First: thanks for this time-saving project!
What's the maintainers' opinion about linters in treefmt-nix?
The docs seem to speak about formatters only, not linters. Also, the name "treefmt" suggests that this is a project about code formatting.
Currently, treefmt-nix offers some linters such as ShellCheck, jsonnet-lint, etc.
Just asking to see what the chances would be for PRs to support more linters like hadolint or Pylint.
Surely, the distinction between formatter and linter isn't always that clear. Some linters have an additional fix mode that may change things, akin to formatting. Technically, most linters in check mode return a non-zero exit status if they discover lints, whereas most formatters exit with status zero even if they changed something (Rufo being an exception unless invoked with --simple-exit).