Skip to content

Commit 80acece

Browse files
committed
ci: automate code formatting and linting with git hooks
1 parent 22b4975 commit 80acece

17 files changed

Lines changed: 147 additions & 119 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ concurrency:
2323
cancel-in-progress: true
2424

2525
jobs:
26-
SwiftLint:
27-
runs-on: ubuntu-latest
28-
steps:
29-
- uses: actions/checkout@v5
30-
- name: GitHub Action for SwiftLint
31-
uses: norio-nomura/action-swiftlint@3.2.1
32-
with:
33-
args: --strict
34-
env:
35-
DIFF_BASE: ${{ github.base_ref }}
3626
macOS:
3727
name: ${{ matrix.name }}
3828
runs-on: ${{ matrix.runsOn }}
@@ -205,23 +195,3 @@ jobs:
205195
with:
206196
name: MergedResult
207197
path: test_output/final
208-
209-
discover-typos:
210-
name: Discover Typos
211-
runs-on: macos-15
212-
env:
213-
DEVELOPER_DIR: /Applications/Xcode_16.4.app/Contents/Developer
214-
steps:
215-
- uses: actions/checkout@v5
216-
217-
- name: Set up Python environment
218-
run: |
219-
python3 -m venv .venv
220-
source .venv/bin/activate
221-
pip install --upgrade pip
222-
pip install codespell
223-
224-
- name: Discover typos
225-
run: |
226-
source .venv/bin/activate
227-
codespell --ignore-words-list="hart,inout,msdos,sur" --skip="./.build/*,./.git/*"

.github/workflows/lint.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
paths:
9+
- "Sources/**"
10+
- ".github/workflows/ci.yml"
11+
- "Tests/**"
12+
13+
concurrency:
14+
group: lint-${{ github.head_ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
lint:
19+
name: lint
20+
runs-on: macos-15
21+
steps:
22+
- uses: actions/checkout@v5
23+
- uses: jdx/mise-action@v3
24+
- name: Run
25+
run: mise run lint
26+
27+
discover-typos:
28+
name: discover-typos
29+
runs-on: macos-15
30+
env:
31+
DEVELOPER_DIR: /Applications/Xcode_16.4.app/Contents/Developer
32+
steps:
33+
- uses: actions/checkout@v5
34+
35+
- name: Set up Python environment
36+
run: |
37+
python3 -m venv .venv
38+
source .venv/bin/activate
39+
pip install --upgrade pip
40+
pip install codespell
41+
42+
- name: Discover typos
43+
run: |
44+
source .venv/bin/activate
45+
codespell --ignore-words-list="hart,inout,msdos,sur" --skip="./.build/*,./.git/*"

Makefile

Lines changed: 0 additions & 19 deletions
This file was deleted.

Mintfile

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ dependencies: [
259259
Bootstrapping development environment
260260

261261
```
262-
make bootstrap
262+
mise install
263263
```
264264

265265
Please feel free to help out with this project! If you see something that could be made better or want a new feature, open up an issue or send a Pull Request!

Sources/ValidatorCore/Classes/Extensions/ValidationResult+Equatable.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ extension ValidationResult: Equatable {
99
public static func == (lhs: ValidationResult, rhs: ValidationResult) -> Bool {
1010
switch (lhs, rhs) {
1111
case (.valid, .valid):
12-
return true
12+
true
1313
case let (.invalid(errors: lhs), .invalid(errors: rhs)):
14-
return lhs.map(\.message).joined() == rhs.map(\.message).joined()
14+
lhs.map(\.message).joined() == rhs.map(\.message).joined()
1515
default:
16-
return false
16+
false
1717
}
1818
}
1919
}

Sources/ValidatorUI/Classes/IUIValidatable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public protocol IUIValidatable: AnyObject {
2121
/// - rule: The validation rule.
2222
///
2323
/// - Returns: A validation result.
24-
func validate<T>(rule: some IValidationRule<T>) -> ValidationResult where T == Input
24+
func validate(rule: some IValidationRule<Input>) -> ValidationResult
2525

2626
/// Validates an input value.
2727
///
@@ -71,7 +71,7 @@ public extension IUIValidatable {
7171
self,
7272
&kValidationRules,
7373
newValue as [any IValidationRule<Input>],
74-
.OBJC_ASSOCIATION_RETAIN_NONATOMIC
74+
.OBJC_ASSOCIATION_RETAIN_NONATOMIC,
7575
)
7676
}
7777
}

Sources/ValidatorUI/Classes/SUI/Extensions/View+Validation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public extension View {
2828
func validation<T>(
2929
_ item: Binding<T>,
3030
rule: some IValidationRule<T>,
31-
action: @escaping (ValidationResult) -> Void
31+
action: @escaping (ValidationResult) -> Void,
3232
) -> some View {
3333
validation(item, rules: [rule], action: action)
3434
}
@@ -51,7 +51,7 @@ public extension View {
5151
func validation<T>(
5252
_ item: Binding<T>,
5353
rules: [any IValidationRule<T>],
54-
action: @escaping (ValidationResult) -> Void
54+
action: @escaping (ValidationResult) -> Void,
5555
) -> some View {
5656
let result = validator.validate(input: item.wrappedValue, rules: rules)
5757
action(result)

Sources/ValidatorUI/Classes/SUI/Extensions/View+ValidationModifier.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ public extension View {
1818
func validate<T, ErrorView: View>(
1919
item: Binding<T>,
2020
rules: [any IValidationRule<T>],
21-
@ViewBuilder content: @escaping ([any IValidationError]) -> ErrorView
21+
@ViewBuilder content: @escaping ([any IValidationError]) -> ErrorView,
2222
) -> some View {
2323
modifier(
2424
ValidationViewModifier(
2525
item: item,
2626
rules: rules,
27-
content: content
28-
)
27+
content: content,
28+
),
2929
)
3030
}
3131

@@ -38,13 +38,13 @@ public extension View {
3838
/// - Returns: A modified view.
3939
func validate<ErrorView: View>(
4040
validationContainer: any IFormValidationContainer,
41-
@ViewBuilder content: @escaping ([any IValidationError]) -> ErrorView
41+
@ViewBuilder content: @escaping ([any IValidationError]) -> ErrorView,
4242
) -> some View {
4343
modifier(
4444
FormValidationViewModifier(
4545
validationContainer: validationContainer,
46-
content: content
47-
)
46+
content: content,
47+
),
4848
)
4949
}
5050
}

Sources/ValidatorUI/Classes/SUI/Managers/FormField/FormField/FormField.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public typealias ValidationPublisher = AnyPublisher<ValidationResult, Never>
1515
public final class FormField<Value>: IFormField {
1616
// MARK: Properties
1717

18-
@Published
1918
/// The value to validate.
19+
@Published
2020
private var value: Value
2121

2222
/// The validation.
@@ -35,7 +35,7 @@ public final class FormField<Value>: IFormField {
3535
public init(
3636
wrappedValue: Value,
3737
validator: IValidator = Validator(),
38-
rules: [any IValidationRule<Value>]
38+
rules: [any IValidationRule<Value>],
3939
) {
4040
value = wrappedValue
4141
self.validator = validator
@@ -57,7 +57,7 @@ public final class FormField<Value>: IFormField {
5757
value: subject,
5858
publisher: publisher,
5959
validator: validator,
60-
rules: rules
60+
rules: rules,
6161
)
6262

6363
manager.append(validator: container)

0 commit comments

Comments
 (0)