Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ci: lint toml files#12384

Draft
xtqqczze wants to merge 1 commit intofish-shell:masterfrom
xtqqczze:taplo
Draft

ci: lint toml files#12384
xtqqczze wants to merge 1 commit intofish-shell:masterfrom
xtqqczze:taplo

Conversation

@xtqqczze
Copy link
Contributor

No description provided.

@xtqqczze xtqqczze marked this pull request as ready for review January 26, 2026 23:43
@danielrainer
Copy link

I had essentially the same idea about a week ago. The main problem I see with our current approach is that we don't enforce consistent formatting for our TOML files, which leads to formatting noise. One thing which would be nice to solve in addition to what this PR currently does is key sorting, so we don't have to bother doing it manually. Taplo can do this with the formatting.reorder_keys = true option. I already had a finished implementation for Taplo, but then I noticed that it is barely maintained anymore and discovered Tombi, which is a lot more opinionated and seems to have automatic schema support for Cargo.toml files. I haven't gotten around to really evaluating it, hence the lack of a PR from my side.

Whichever option we go with, it should be something we're all comfortable running locally, ideally via the editor, since dealing with autoformatting which isn't available locally is a huge pain. This means that we should also integrate the TOML formatter into build_tools/style.fish. For Taplo, I already did that:

diff --git a/build_tools/style.fish b/build_tools/style.fish
index b8fd1f8a04..22dd4e1fa2 100755
--- a/build_tools/style.fish
+++ b/build_tools/style.fish
@@ -30,7 +30,8 @@
     if not set -l -q _flag_force; and not set -l -q _flag_check
         # Potential for false positives: Not all fish files are formatted, see the `fish_files`
         # definition below.
-        set -l relevant_uncommitted_changes (git status --porcelain --short --untracked-files=all | sed -e 's/^ *[^ ]* *//' | grep -E '.*\.(fish|py|rs)$')
+        set -l relevant_uncommitted_changes (git status --porcelain --short --untracked-files=all |
+            sed -e 's/^ *[^ ]* *//' | grep -E '.*\.(fish|py|rs|toml)$')
         if set -q relevant_uncommitted_changes[1]
             for changed_file in $relevant_uncommitted_changes
                 echo $changed_file
@@ -45,12 +46,14 @@
     end
     set fish_files $workspace_root/{benchmarks,build_tools,etc,share}/**.fish
     set python_files $workspace_root
+    set toml_files $workspace_root/**.toml
 else
     # Format the files specified as arguments.
     set -l files $argv
     set fish_files (string match -r '^.*\.fish$' -- $files)
     set python_files (string match -r '^.*\.py$' -- $files)
     set rust_files (string match -r '^.*\.rs$' -- $files)
+    set toml_files (string match -r '^.*\.toml$' -- $files)
 end
 
 set -l red (set_color red)
@@ -121,3 +124,18 @@
         end
     end
 end
+
+if set -q toml_files[1]
+    if not type -q taplo
+        echo
+        echo $yellow'Please install `taplo` to style TOML'$normal
+        exit 127
+    end
+    echo === Running "$green"taplo fmt"$normal"
+    if set -l -q _flag_check
+        taplo fmt --check $toml_files
+        or die "TOML files are not formatted correctly."
+    else
+        taplo fmt $toml_files
+    end
+end

Then we also don't need to explicitly run the formatter in CI, installing it is enough since the style.fish script is already used.

@xtqqczze xtqqczze marked this pull request as draft January 29, 2026 00:50
@krobelus
Copy link
Contributor

if we don't want 4-space indent in TOML files, we'd also want to update .editorconfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants