Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for linters #11

Open
zimbatm opened this issue Jan 18, 2021 · 9 comments
Open

Add support for linters #11

zimbatm opened this issue Jan 18, 2021 · 9 comments
Labels
enhancement New feature or request
Milestone

Comments

@zimbatm
Copy link
Member

zimbatm commented Jan 18, 2021

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.

@zimbatm zimbatm added the enhancement New feature or request label Jan 18, 2021
@zimbatm zimbatm added this to the Release 0.2 milestone Feb 27, 2021
@zimbatm zimbatm modified the milestones: Release 0.2, Release 0.3 Apr 10, 2021
@zimbatm zimbatm modified the milestones: Release 0.3, Release 0.4 May 7, 2021
@zimbatm
Copy link
Member Author

zimbatm commented Dec 13, 2021

@9999years
Copy link

I would like this to work around astral-sh/ruff#8232 by running ruff check --fix && ruff format.

@zimbatm
Copy link
Member Author

zimbatm commented Feb 19, 2024

Something like this should work:

[formatter.ruff]
command = "sh"
options = ["-c", "ruff check \"$@\" && ruff format \"$@\"", "--"]
includes = ["*.py", "*.pyi"]

@evolutics
Copy link

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).

brianmcgee pushed a commit that referenced this issue May 13, 2024
The package was created before Go introduced their own "errors"
package.

Trade the better juju errors semantic for a smaller dependency tree.

Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/11
Co-authored-by: zimbatm <[email protected]>
Co-committed-by: zimbatm <[email protected]>
brianmcgee added a commit that referenced this issue May 13, 2024
Stacked on top of #11

Co-authored-by: Brian McGee <[email protected]>
Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/13
Co-authored-by: zimbatm <[email protected]>
Co-committed-by: zimbatm <[email protected]>
@sellout
Copy link

sellout commented Oct 22, 2024

This would be very helpful.

I recently changed my treefmt-nix config to use treefmt v2 instead of v1 in order to avoid #153, but now I find that v2 errors with “path '…' matched multiple formatters/pipelines [hlint ormolu]” on all my Haskell code.

I’m currently waffling on whether I should go back to v1 for Haskell projects (which skips formatting many things) or disable hlint.

@brianmcgee
Copy link
Member

brianmcgee commented Oct 22, 2024

@sellout which version of v2 are you using?

That error message is old, in fact I don't think that's even in 2.0.1: ce14ee8 Sounds like you're using a 2.0.0 rc release.

The latest is 2.0.5.

@sellout
Copy link

sellout commented Oct 22, 2024

@sellout which version of v2 are you using?

That error message is old, in fact I don't think that's even in 2.0.1: ce14ee8 Sounds like you're using a 2.0.0 rc release.

Ah, whoops – it’s 2.0.0-rc2, from Nixpkgs 24.05 (the current release). I usually check these things, but assumed this issue was specifically about the problem of having multiple formatters.

Thanks – I’ll overlay a newer one.

@brianmcgee
Copy link
Member

@sellout multiple formatters on the same files are not a problem anymore: https://treefmt.com/configure#same-file-multiple-formatters

@sellout
Copy link

sellout commented Oct 22, 2024

@sellout multiple formatters on the same files are not a problem anymore: https://treefmt.com/configure#same-file-multiple-formatters

Thanks – I pulled 2.0.5 from nixpkgs-unstable and the formatting is working better than ever. No notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants