Skip to content

Commit

Permalink
Adopt hoistPatternLet rule
Browse files Browse the repository at this point in the history
  • Loading branch information
calda committed May 12, 2021
1 parent 785f282 commit 7c8cfe2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,30 @@ _You can enable the following settings in Xcode by running [this script](resourc

</details>

* <a id='destructure-inline-let'></a> (<a href='#destructure-inline-let'>link</a>) **When destructuring an enum case or a tuple, place the `let` keyword inline, adjacent to each individual property assignment.** [![SwiftFormat: hoistPatternLet](https://img.shields.io/badge/SwiftFormat-hoistPatternLet-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#hoistPatternLet)

<details>

```swift
// WRONG
switch result {
case let .value(value):
// ...
case let .error(errorCode, errorReason):
// ...
}

// RIGHT
switch result {
case .value(let value):
// ...
case .error(let errorCode, let errorReason):
// ...
}
```

</details>

* <a id='attributes-on-prev-line'></a>(<a href='#attributes-on-prev-line'>link</a>) **Place function/type attributes on the line above the declaration**. [![SwiftFormat: wrapAttributes](https://img.shields.io/badge/SwiftFormat-wrapAttributes-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#wrapAttributes)

<details>
Expand Down
3 changes: 2 additions & 1 deletion resources/airbnb.swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
--enumthreshold 20 # organizeDeclarations
--organizetypes class,struct,enum,extension # organizeDeclarations
--extensionacl on-declarations # extensionAccessControl
--patternlet inline # hoistPatternLet
--swiftversion 5.1

# rules
--rules anyObjectProtocol,redundantParens,redundantReturn,redundantSelf,sortedImports,strongifiedSelf,trailingCommas,trailingSpace,wrapArguments,wrapMultilineStatementBraces,indent,wrapAttributes,organizeDeclarations,markTypes,extensionAccessControl,duplicateImports,redundantType
--rules anyObjectProtocol,redundantParens,redundantReturn,redundantSelf,sortedImports,strongifiedSelf,trailingCommas,trailingSpace,wrapArguments,wrapMultilineStatementBraces,indent,wrapAttributes,organizeDeclarations,markTypes,extensionAccessControl,duplicateImports,redundantType,hoistPatternLet

0 comments on commit 7c8cfe2

Please sign in to comment.