numtide / treefmt

one CLI to format your repo [maintainers=@zimbatm,@brianmcgee]
https://treefmt.com
MIT License
621 stars 38 forks source link

Global excludes are not effective #324

Closed Mic92 closed 5 months ago

Mic92 commented 5 months ago

I am trying to exclude the sops directory like this:

...
            treefmt = {
              projectRootFile = ".git/config";
              programs.terraform.enable = true;
              programs.shellcheck.enable = true;
              programs.deno.enable = true;

              settings.excludes = [
                # generated files
+               "sops/*"
                "terraform.tfstate"
                "*.tfvars.sops.json"
                "nixos-vars.json"
                "secrets.yaml"
              ];
              programs.nixfmt-rfc-style.enable = true;
              settings.formatter.nixfmt-rfc-style.excludes = [
                # generated files
                "node-env.nix"
                "node-packages.nix"
                "composition.nix"
              ];
            };
..

But treefmt still tries to format files in the sops directory.

$ LOG_LEVEL=10 nix fmt -- --no-cache
...
DEBU format | deno: match: /home/joerg/work/clan/clan-infra/sops/machines/web01/key.json
DEBU format | deno: match: /home/joerg/work/clan/clan-infra/sops/users/dave/key.json
DEBU format | deno: match: /home/joerg/work/clan/clan-infra/sops/users/joerg/key.json
DEBU format | deno: match: /home/joerg/work/clan/clan-infra/sops/users/lassulus/key.json
DEBU format | deno: match: /home/joerg/work/clan/clan-infra/sops/users/qubasa/key.json
...

It works if use the same glob in settings.formatter.deno.excludes.

jaen commented 5 months ago

@Mic92 I don't know if you're trying to use V1 or V2, but at least for V2 HEAD using settings.global.excludes seems to work properly.

Mic92 commented 5 months ago

Yes. I merged the fix for HEAD today :) https://github.com/numtide/treefmt/pull/325