Skip to content

Commit

Permalink
Add rule to place doc comments before any attributes (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
calda authored Jul 27, 2024
1 parent c2b4614 commit a09950f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ let package = Package(

.binaryTarget(
name: "swiftformat",
url: "https://github.com/calda/SwiftFormat/releases/download/0.55-beta-4/SwiftFormat.artifactbundle.zip",
checksum: "ebdb5cefe050099d2cbc0e00a0d45abc3f45e763c7cd6b849a1113026b2b2a3b"),
url: "https://github.com/calda/SwiftFormat/releases/download/0.55-beta-6/SwiftFormat.artifactbundle.zip",
checksum: "c4faeb1068eece2b644192afc1a35a82a81935794034d2efaa3f44ddd8a4b8d4"),

.binaryTarget(
name: "SwiftLintBinary",
Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,9 @@ _You can enable the following settings in Xcode by running [this script](resourc
var oldestMoons: [Moon]

}
```swift

```

```swift
// WRONG. These long, complex attributes should be written on the previous line.
struct RocketFactory {

Expand Down Expand Up @@ -1870,6 +1870,26 @@ _You can enable the following settings in Xcode by running [this script](resourc

</details>

* <a id='doc-comments-before-attributes'></a>(<a href='#doc-comments-before-attributes'>link</a>) **Place doc comments for a declaration before any attributes.** [![SwiftFormat: docCommentsBeforeAttributes](https://img.shields.io/badge/SwiftFormat-docCommentsBeforeAttributes-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#docCommentsBeforeAttributes)

<details>

```swift
// WRONG

@MainActor
/// A spacecraft with everything you need to explore the universe.
struct Spaceship { }

// RIGHT

/// A spacecraft with everything you need to explore the universe.
@MainActor
struct Spaceship { }
```

</details>

* <a id='whitespace-around-comment-delimiters'></a>(<a href='#whitespace-around-comment-delimiters'>link</a>) Include spaces or newlines before and after comment delimiters (`//`, `///`, `/*`, and `*/`) [![SwiftFormat: spaceAroundComments](https://img.shields.io/badge/SwiftFormat-spaceAroundComments-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#spaceAroundComments) [![SwiftFormat: spaceInsideComments](https://img.shields.io/badge/SwiftFormat-spaceInsideComments-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#spaceInsideComments)

<details>
Expand Down
1 change: 1 addition & 0 deletions Sources/AirbnbSwiftFormatTool/airbnb.swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
--rules enumNamespaces
--rules blockComments
--rules docComments
--rules docCommentsBeforeAttributes
--rules spaceAroundComments
--rules spaceInsideComments
--rules blankLinesAtStartOfScope
Expand Down

0 comments on commit a09950f

Please sign in to comment.