Skip to content

Commit

Permalink
feat(treefmt): Add more formatters/linters
Browse files Browse the repository at this point in the history
- We now use Statix and Deadnix to reduce the need for PRs like #390;
- We are now also formatting TOML, Ruby, JSON, CSS and YAML;
- We also lint shell scripts with shellcheck and format them with shfmt.

Signed-off-by: Fernando Rodrigues <[email protected]>
  • Loading branch information
SigmaSquadron committed Oct 19, 2024
1 parent 0d370bb commit a080694
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
11 changes: 11 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,20 @@
devShells = forAllSystems (system: {
default = nixpkgsFor.${system}.mkShell {
buildInputs = with nixpkgsFor.${system}; [
deadnix
nixfmt-rfc-style
nodePackages.prettier
ruby
ruby.devdoc
rufo
shellcheck
shfmt
taplo
(pkgs.writeShellScriptBin "statix-fix" ''
for file in "''$@"; do
${lib.getExe statix} fix "$file"
done
'')
(python3.withPackages (pyPkgs: [
pyPkgs.python-lsp-server
pyPkgs.black
Expand Down
51 changes: 51 additions & 0 deletions treefmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,61 @@
command = "nixfmt"
includes = ["*.nix"]

[formatter.deadnix]
command = "deadnix"
options = ["--edit"]
includes = ["*.nix"]

[formatter.statix]
command = "statix-fix"
includes = ["*.nix"]

[formatter.black]
command = "black"
includes = ["*.py", "*.pyi"]

[formatter.isort]
command = "isort"
includes = ["*.py", "*.pyi"]

[formatter.taplo]
command = "taplo"
options = ["format"]
includes = ["*.toml"]

[formatter.shellcheck]
command = "shellcheck"
includes = ["*.sh", "*.bash", "*.envrc", "*.envrc.*"]
priority = 0

[formatter.shfmt]
command = "shfmt"
options = [
"--write",
"--simplify",
"--indent=2",
"--binary-next-line",
"--case-indent",
"--space-redirects",
"--apply-ignore",
]
includes = ["*.sh", "*.bash", "*.envrc", "*.envrc.*"]
priority = 1

[formatter.rufo]
command = "rufo"
options = ["--simple-exit"]
includes = [
"*.rb",
"*.arb",
"*.rbx",
"*.rbw",
"*.gemfile",
"*.gemspec",
"*.ruby",
]

[formatter.prettier]
command = "prettier"
options = ["--write"]
includes = ["*.css", "*.json", "*.md", "*.yml"]

0 comments on commit a080694

Please sign in to comment.