diff --git a/Package.swift b/Package.swift index c870ed9..009a344 100644 --- a/Package.swift +++ b/Package.swift @@ -42,8 +42,8 @@ let package = Package( .binaryTarget( name: "swiftformat", - url: "https://github.com/calda/SwiftFormat/releases/download/0.55-beta-15/SwiftFormat.artifactbundle.zip", - checksum: "5da82a61d4a29e77acc5a2e8668c40168970e1d6b2078bdfcb377b6f6ef35039"), + url: "https://github.com/calda/SwiftFormat/releases/download/0.55-beta-17/SwiftFormat.artifactbundle.zip", + checksum: "659bdcccc69a6e5ccbd273f0fb7b7af9655d5fa7acc17c4fb3deba6a7b1e9a5b"), .binaryTarget( name: "SwiftLintBinary", diff --git a/README.md b/README.md index a3e8439..89b6147 100644 --- a/README.md +++ b/README.md @@ -3745,6 +3745,35 @@ _You can enable the following settings in Xcode by running [this script](resourc +* (link) **Prefer using the `@Entry` macro to define properties inside `EnvironmentValues`**. When adding properties to SwiftUI `EnvironemtnValues`, prefer using the compiler-synthesized property implementation when possible. [![SwiftFormat: environmentEntry](https://img.shields.io/badge/SwiftFormat-environmentEntry-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/develop/Rules.md#environmentEntry) + +
+ + ### Why? + + Manually-implemented environment keys are verbose and it is considered a legacy pattern. `@Entry` was specifically intended to be a replacement considering it was backported to iOS 13. + + ```swift + /// WRONG: The `EnvironmentValues` property depends on `IsSelectedEnvironmentKey` + struct IsSelectedEnvironmentKey: EnvironmentKey { + static var defaultValue: Bool { false } + } + + extension EnvironmentValues { + var isSelected: Bool { + get { self[IsSelectedEnvironmentKey.self] } + set { self[IsSelectedEnvironmentKey.self] = newValue } + } + } + + /// RIGHT: The `EnvironmentValues` property uses the @Entry macro + extension EnvironmentValues { + @Entry var isSelected: Bool = false + } + ``` + +
+ * (link) **Avoid using `()` as a type**. Prefer `Void`.
diff --git a/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat b/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat index 9521532..3113dea 100644 --- a/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat +++ b/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat @@ -56,6 +56,7 @@ --rules consecutiveBlankLines --rules duplicateImports --rules extensionAccessControl +--rules environmentEntry --rules hoistPatternLet --rules indent --rules markTypes