From d037bc1de400710c0fd9ce235e145b106b2730b6 Mon Sep 17 00:00:00 2001 From: baegteun Date: Thu, 7 Mar 2024 20:27:29 +0900 Subject: [PATCH 1/5] =?UTF-8?q?:wrench:=20::=20[#417]=20SwiftLint,=20Swift?= =?UTF-8?q?Format=20config=20=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .swiftformat | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ .swiftlint.yml | 25 +++++++++----------- 2 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 .swiftformat diff --git a/.swiftformat b/.swiftformat new file mode 100644 index 000000000..1a57e0ea0 --- /dev/null +++ b/.swiftformat @@ -0,0 +1,64 @@ + +--exclude fastlane,Tuist,Dependencies,Carthage + +# options +--maxwidth 120 +--indent 4 +--trimwhitespace always # trailingSpace +--lineaftermarks false # fileHeader +--wraparguments before-first # wrapArguments +--wrapparameters before-first # wrapArguments +--wrapcollections before-first # wrapArguments + +# rules +--rules anyObjectProtocol +--rules blankLineAfterImports +--rules blankLinesAroundMark +--rules blankLinesAtEndOfScope +--rules blankLinesAtStartOfScope +--rules blankLinesBetweenImports +--rules blankLinesBetweenScopes +--rules braces +--rules consecutiveBlankLines +--rules consecutiveSpaces +--rules docComments +--rules duplicateImports +--rules elseOnSameLine +--rules emptyBraces +--rules enumNamespaces +--rules extensionAccessControl +--rules fileHeader +--rules hoistAwait +--rules hoistPatternLet +--rules hoistTry +--rules initCoderUnavailable +--rules indent +--rules isEmpty +--rules leadingDelimiters +--rules linebreakAtEndOfFile +--rules modifierOrder +--rules numberFormatting +--rules opaqueGenericParameters +--rules redundantExtensionACL +--rules redundantOptionalBinding +--rules redundantParens +--rules redundantVoidReturnType +--rules semicolons +--rules sortImports +--rules spaceAroundBraces +--rules spaceAroundBrackets +--rules spaceAroundComments +--rules spaceAroundGenerics +--rules spaceAroundOperators +--rules spaceInsideBraces +--rules spaceInsideBrackets +--rules spaceInsideComments +--rules spaceInsideGenerics +--rules spaceInsideParens +--rules todos +--rules trailingClosures +--rules trailingSpace +--rules typeSugar +--rules void +--rules wrap +--rules wrapArguments \ No newline at end of file diff --git a/.swiftlint.yml b/.swiftlint.yml index 2bdb24d37..b58a91d72 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -5,17 +5,14 @@ excluded: force_cast: # From https://realm.github.io/SwiftLint/force_cast.html warning # 강제 캐스팅은 error에서 warning으로 변경 -disabled_rules: - - trailing_whitespace - - vertical_whitespace - - colon - - comma - - comment_spacing # 주석 여백 - - mark # //MARK 관련 warning - - opening_brace # 괄호 열 때 줄바꿈을 했는지 안했는지, (안했으면 warning) - - line_length # 한줄에 글자 수 제한 , warning: 120, error: 200 (default) - - statement_position # if는 반드시 else로 끝나야한다. - - identifier_name #변수명 글자 수 제한 - - function_body_length - - function_parameter_count - - nesting +identifier_name: + min_length: + warning: 1 + +nesting: + type_label: + warning: 3 + +type_name: + max_length: + warning: 60 From 762e69805a03be6a304a6b40f48c9e015cac8373 Mon Sep 17 00:00:00 2001 From: baegteun Date: Thu, 7 Mar 2024 20:54:19 +0900 Subject: [PATCH 2/5] =?UTF-8?q?:wrench:=20::=20[#417]=20pre-commit=20/=20C?= =?UTF-8?q?ommit=EC=9D=84=20=ED=95=98=EA=B8=B0=20=EC=A0=84,=20SwiftFormat?= =?UTF-8?q?=EC=9D=84=20=EB=8F=8C=EB=A6=B0=20=ED=9B=84=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .githooks/.gitkeep | 0 .githooks/pre-commit | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) delete mode 100644 .githooks/.gitkeep create mode 100644 .githooks/pre-commit diff --git a/.githooks/.gitkeep b/.githooks/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 000000000..99a9e6f91 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,42 @@ +#!/bin/sh + +FORMAT=$(which swiftformat) + +if [[ -e "${FORMAT}" ]]; then + echo "🚀 SwiftFormat 시작..." + echo "🔍 SwiftFormat 적용 경로: $(pwd)/Projects" +else + echo "SwiftFormat이 존재하지 않습니다. 설치해주세요 ! 'brew install swiftformat'" + exit 1 +fi + +RESULT=$($FORMAT ./Projects --config .swiftformat) + +if [ "$RESULT" == '' ]; then + printf "\n 🎉 SwiftFormat 적용을 완료했습니다 !! \n" + git add . +else + echo "" + printf "❌ SwiftFormat Failed 아래 내용을 확인해주세요 \n" + while read -r line; do + FILEPATH=$(echo $line | cut -d : -f 1) + L=$(echo $line | cut -d : -f 2) + C=$(echo $line | cut -d : -f 3) + TYPE=$(echo $line | cut -d : -f 4 | cut -c 2-) + MESSAGE=$(echo $line | cut -d : -f 5 | cut -c 2-) + DESCRIPTION=$(echo $line | cut -d : -f 6 | cut -c 2-) + if [ $TYPE == 'warning' ]; then + printf "\n 🚧 $TYPE\n" + printf " $FILEPATH:$L:$C\n" + printf " 📌 $MESSAGE: - $DESCRIPTION\n" + exit 0 + elif [ $TYPE == 'error' ]; then + printf "\n 🚨 $TYPE\n" + fi + printf " ✅ $FILEPATH:$L:$C\n" + printf " 📌 $MESSAGE: - $DESCRIPTION\n" + done <<< "$RESULT" + + printf "\n 🚑 커밋실패!! SwiftFormat 실행이 실패하였습니다 🥺 \n" + exit 1 +fi \ No newline at end of file From 954acbd1487a9df582c94bba616fe03998883563 Mon Sep 17 00:00:00 2001 From: baegteun Date: Thu, 7 Mar 2024 21:03:29 +0900 Subject: [PATCH 3/5] =?UTF-8?q?:wrench:=20::=20[#417]=20.swiftlint.yml=20/?= =?UTF-8?q?=20Plugin=20=ED=8C=8C=EC=9D=BC=EC=9D=84=20swiftlint=EC=9D=98=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=EB=A1=9C=EB=B6=80=ED=84=B0=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .swiftlint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.swiftlint.yml b/.swiftlint.yml index b58a91d72..ff404805e 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,6 +1,7 @@ excluded: - "**/*/NeedleGenerated.swift" - "Tuist" + - "Plugin" force_cast: # From https://realm.github.io/SwiftLint/force_cast.html warning # 강제 캐스팅은 error에서 warning으로 변경 From 5690ee8782ee698ccf052653252a1f972e1fa7ac Mon Sep 17 00:00:00 2001 From: baegteun Date: Fri, 8 Mar 2024 23:45:37 +0900 Subject: [PATCH 4/5] =?UTF-8?q?:hammer:=20::=20[#417]=20=EC=9E=90=EB=8F=99?= =?UTF-8?q?=20add=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20make=20format=20?= =?UTF-8?q?=EB=AA=85=EB=A0=B9=EC=96=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .githooks/pre-commit | 1 - Makefile | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 99a9e6f91..208c401d8 100644 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -14,7 +14,6 @@ RESULT=$($FORMAT ./Projects --config .swiftformat) if [ "$RESULT" == '' ]; then printf "\n 🎉 SwiftFormat 적용을 완료했습니다 !! \n" - git add . else echo "" printf "❌ SwiftFormat Failed 아래 내용을 확인해주세요 \n" diff --git a/Makefile b/Makefile index 164be2f8e..089a56b90 100644 --- a/Makefile +++ b/Makefile @@ -25,4 +25,7 @@ module: swift Scripts/GenerateModule.swift setup: - sh Scripts/Setup.sh \ No newline at end of file + sh Scripts/Setup.sh + +format: + swiftformat ./Projects --config .swiftformat \ No newline at end of file From b5c13f114fc9a1b0ba3f6618af899c26c4ac1e46 Mon Sep 17 00:00:00 2001 From: baegteun Date: Fri, 8 Mar 2024 23:47:43 +0900 Subject: [PATCH 5/5] =?UTF-8?q?:passport=5Fcontrol:=20::=20[#417]=20pre-co?= =?UTF-8?q?mmit=20=EA=B6=8C=ED=95=9C=20=EB=B6=80=EC=97=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .githooks/pre-commit | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit old mode 100644 new mode 100755