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

automatically infer all applicable formatters from file extensions #324

Open
maxheld83 opened this issue Mar 25, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@maxheld83
Copy link

Is your feature request related to a problem? Please describe.

Not a problem, I'm just too lazy to write a lot of, for example, this:

programs = {
  actionlint.enable = true;
  beautysh.enable = true;
}

for a bunch of projects.

Describe the solution you'd like

I'd like there to be a function in lib I can call, which would return the applicable above attribute set, depending on which files are found in the repo.
I could then just add treefmt-nix to a project, and it would automatically figure out the required (linter) dependencies and run them.

This would be very helpful, especially for ancillary/config files like *.yaml, *.Make, Dockerfile, etc. which are easily forgotten.

Describe alternatives you've considered

I could get the same behavior by just creating a version of treefmt-nix with all the linters enabled, but for most projects, this would cause a lot of unnecessary dependency bloat.

Additional context

I'd imagine this would depend on there already existing some readily-available "default" mapping between formatter and file extension (i.e. *.md <-> markdownlint or whatever).
I assumed this would already exist somewhere within treefmt or treefmt-nix (otherwise, how can --on-unmatched work?), but I could not find it in the source, so maybe I'm missing something.

I'm way too new to nix to be able to offer to PR this feature, but perhaps if others like it, and I learn more, at some point I could 🙂.

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

1 participant