From b8819dacc3d1553a4781b0e3e0351ca137cdfcbe Mon Sep 17 00:00:00 2001 From: Tony Li Date: Thu, 19 Mar 2026 10:12:25 +1300 Subject: [PATCH] Run a Claude Code hook to run swift-format --- .claude/settings.json | 15 +++++++++++++++ .swift-format | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .swift-format diff --git a/.claude/settings.json b/.claude/settings.json index 049ec26d33c2..18c98effad5d 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -13,5 +13,20 @@ "Bash(git:log,status,diff,branch)" ], "deny": [] + }, + "hooks": { + "PostToolUse": [ + { + "matcher": "Write|Edit", + "hooks": [ + { + "type": "command", + "command": "jq -r '.tool_input.file_path' | { read -r f; case \"$f\" in *.swift) xcrun swift format --in-place \"$f\" ;; esac; } 2>/dev/null || true", + "timeout": 30, + "statusMessage": "Formatting Swift..." + } + ] + } + ] } } diff --git a/.swift-format b/.swift-format new file mode 100644 index 000000000000..49f7afe2d6f5 --- /dev/null +++ b/.swift-format @@ -0,0 +1,16 @@ +{ + "version": 1, + "indentation": { + "spaces": 4 + }, + "lineLength": 120, + "spacesBeforeEndOfLineComments": 1, + "lineBreakBeforeEachArgument": true, + "prioritizeKeepingFunctionOutputTogether": true, + "lineBreakAroundMultilineExpressionChainComponents": true, + "indentConditionalCompilationBlocks": false, + "multiElementCollectionTrailingCommas": false, + "rules": { + "OmitExplicitReturns": true + } +}