Skip to content

Commit

Permalink
Add SwiftFormat void rule (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel-jimenez-0529 authored Sep 3, 2024
1 parent ae60ffe commit 6022593
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3677,6 +3677,34 @@ _You can enable the following settings in Xcode by running [this script](resourc

</details>

* <a id='void-type'></a>(<a href='#void-type'>link</a>) **Avoid using `()` as a type**. Prefer `Void`.

<details>

```swift
// WRONG
let result: Result<(), Error>

// RIGHT
let result: Result<Void, Error>
```
</details>

* <a id='void-instance'></a>(<a href='#void-instance'>link</a>) **Avoid using `Void()` as an instance of `Void`**. Prefer `()`.

<details>

```swift
let completion: (Result<Void, Error>) -> Void

// WRONG
completion(.success(Void()))

// RIGHT
completion(.success(()))
```
</details>

**[ back to top](#table-of-contents)**

## File Organization
Expand Down
1 change: 1 addition & 0 deletions Sources/AirbnbSwiftFormatTool/airbnb.swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
--rules preferForLoop
--rules conditionalAssignment
--rules wrapMultilineConditionalAssignment
--rules void
--rules blankLineAfterSwitchCase
--rules consistentSwitchCaseSpacing
--rules semicolons
Expand Down
1 change: 0 additions & 1 deletion Sources/AirbnbSwiftFormatTool/swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ only_rules:
- legacy_constructor
- legacy_nsgeometry_functions
- unused_optional_binding
- void_return # TODO: Replace with SwiftFormat void rule
- unowned_variable_capture
- custom_rules

Expand Down

0 comments on commit 6022593

Please sign in to comment.