diff --git a/.gitignore b/.gitignore index 536ad55..b69502f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .build .swiftpm -.DS_Store \ No newline at end of file +.DS_Store +.vscode \ No newline at end of file diff --git a/README.md b/README.md index 2f14f80..161ee3a 100644 --- a/README.md +++ b/README.md @@ -2191,6 +2191,50 @@ _You can enable the following settings in Xcode by running [this script](resourc +* (link) **Remove blank lines between chained functions.** [![SwiftFormat: blanklinesbetweenchainedfunctions](https://img.shields.io/badge/SwiftFormat-blankLinesBetweenChainedFunctions-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/main/Rules.md#blanklinesbetweenchainedfunctions) + +
+ + #### Why? + + Improves readability and maintainability, making it easier to see the sequence of functions that are applied to the object. + + ```swift + // WRONG + var innerPlanetNames: [String] { + planets + .filter { $0.isInnerPlanet } + + .map { $0.name } + } + + // WRONG + var innerPlanetNames: [String] { + planets + .filter { $0.isInnerPlanet } + + // Gets the name of the inner planet + .map { $0.name } + } + + // RIGHT + var innerPlanetNames: [String] { + planets + .filter { $0.isInnerPlanet } + .map { $0.name } + } + + // RIGHT + var innerPlanetNames: [String] { + planets + .filter { $0.isInnerPlanet } + // Gets the name of the inner planet + .map { $0.name } + } + ``` + +
+ ### Closures * (link) **Favor `Void` return types over `()` in closure declarations.** If you must specify a `Void` return type in a function declaration, use `Void` rather than `()` to improve readability. [![SwiftLint: void_return](https://img.shields.io/badge/SwiftLint-void__return-007A87.svg)](https://realm.github.io/SwiftLint/void_return) diff --git a/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat b/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat index bcb274a..aa50a09 100644 --- a/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat +++ b/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat @@ -104,3 +104,4 @@ --rules consistentSwitchStatementSpacing --rules semicolons --rules propertyType +--rules blankLinesBetweenChainedFunctions \ No newline at end of file