From c2eab3b43d142cc54d02aee3af9e9f80a51090dd Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Fri, 20 Feb 2026 08:39:20 -0500 Subject: [PATCH] macos: add root-level .swiftlint.yml In order to support running from both the repository root and from within Xcode project, and to keep things generally organized, our primary .swiftlint.yml configuration file lives under macos/. This change introduces a root-level .swiftlint.yml which limits the file scope to macos/ and then includes macos/.swiftlint.yml for the rest of the directives. This unlocks a few benefits: - We no longer need to pass an explicit `macos` path argument in any of our invocations. SwiftLint will do the right thing when run either from the repository root or from within the macos/ directory. - It lets us easily exclude the macos/build/ directory (and re-enable the 'deployment_target' rule). In the previous setup, this was more challenging than you'd expect due to SwiftLint's path resolution rules and required passing even more arguments like `--working-directory`. The only downside is adding a new file to the repository root, but that feels like the right trade-off given the benefits and conveniences. --- .github/workflows/test.yml | 3 ++- .swiftlint.yml | 2 ++ AGENTS.md | 2 +- CODEOWNERS | 1 + HACKING.md | 6 +++--- macos/.swiftlint.yml | 4 +++- macos/Ghostty.xcodeproj/project.pbxproj | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 .swiftlint.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4d7b1292b..ba34de7e1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,7 @@ jobs: with: filters: | macos: + - '.swiftlint.yml' - 'macos/**' required: @@ -963,7 +964,7 @@ jobs: useDaemon: false # sometimes fails on short jobs - name: swiftlint check - run: nix develop -c swiftlint lint --strict macos + run: nix develop -c swiftlint lint --strict alejandra: if: github.repository == 'ghostty-org/ghostty' diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 000000000..7f1b56883 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,2 @@ +included: macos +child_config: macos/.swiftlint.yml diff --git a/AGENTS.md b/AGENTS.md index 949bf588e..21645e4d2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,7 +8,7 @@ A file for [guiding coding agents](https://agents.md/). - **Test (Zig):** `zig build test` - **Test filter (Zig)**: `zig build test -Dtest-filter=` - **Formatting (Zig)**: `zig fmt .` -- **Formatting (Swift)**: `swiftlint lint --fix macos` +- **Formatting (Swift)**: `swiftlint lint --fix` - **Formatting (other)**: `prettier -w .` ## Directory Structure diff --git a/CODEOWNERS b/CODEOWNERS index 7e471d1b8..23c95583c 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -137,6 +137,7 @@ /dist/macos/ @ghostty-org/macos /pkg/apple-sdk/ @ghostty-org/macos /pkg/macos/ @ghostty-org/macos +/.swiftlint.yml @ghostty-org/macos # Renderer /src/renderer.zig @ghostty-org/renderer diff --git a/HACKING.md b/HACKING.md index 23657cea5..7ba584881 100644 --- a/HACKING.md +++ b/HACKING.md @@ -194,7 +194,7 @@ are modifying Swift code, you may want to install it locally and run this from the repo root before you commit: ``` -swiftlint lint --fix macos +swiftlint lint --fix ``` Make sure your SwiftLint version matches the version in [devShell.nix](https://github.com/ghostty-org/ghostty/blob/main/nix/devShell.nix). @@ -202,13 +202,13 @@ Make sure your SwiftLint version matches the version in [devShell.nix](https://g Nix users can use the following command to format with SwiftLint: ``` -nix develop -c swiftlint lint --fix macos +nix develop -c swiftlint lint --fix ``` To check for violations without auto-fixing: ``` -nix develop -c swiftlint lint --strict macos +nix develop -c swiftlint lint --strict ``` ### Updating the Zig Cache Fixed-Output Derivation Hash diff --git a/macos/.swiftlint.yml b/macos/.swiftlint.yml index 8f76034af..a3bd7fc22 100644 --- a/macos/.swiftlint.yml +++ b/macos/.swiftlint.yml @@ -2,6 +2,9 @@ # check_for_updates: false +excluded: + - build + disabled_rules: - cyclomatic_complexity - file_length @@ -13,7 +16,6 @@ disabled_rules: - type_body_length # TODO - - deployment_target - for_where - force_cast - line_length diff --git a/macos/Ghostty.xcodeproj/project.pbxproj b/macos/Ghostty.xcodeproj/project.pbxproj index e69331367..49d8132e8 100644 --- a/macos/Ghostty.xcodeproj/project.pbxproj +++ b/macos/Ghostty.xcodeproj/project.pbxproj @@ -509,7 +509,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "[[ -z \"$GITHUB_ACTIONS\" ]] || exit 0;\n\nSWIFTLINT=\"\"\nif command -v swiftlint >/dev/null 2>&1; then\n SWIFTLINT=\"$(command -v swiftlint)\"\nelif [[ -f \"/opt/homebrew/bin/swiftlint\" ]]; then\n SWIFTLINT=\"/opt/homebrew/bin/swiftlint\"\nfi\n\nif [[ -n \"$SWIFTLINT\" ]]; then\n \"$SWIFTLINT\" lint --quiet \"$SRCROOT\"\nfi\n"; + shellScript = "[[ -z \"$GITHUB_ACTIONS\" ]] || exit 0;\n\nSWIFTLINT=\"\"\nif command -v swiftlint >/dev/null 2>&1; then\n SWIFTLINT=\"$(command -v swiftlint)\"\nelif [[ -f \"/opt/homebrew/bin/swiftlint\" ]]; then\n SWIFTLINT=\"/opt/homebrew/bin/swiftlint\"\nfi\n\nif [[ -n \"$SWIFTLINT\" ]]; then\n \"$SWIFTLINT\" lint --quiet\nfi\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */