Skip to content

Commit 80a2745

Browse files
authored
Set default value for config attribute of swiftformat_format (#14)
Set default value for the swiftformat config to be `@//:.swiftformat`.
1 parent 6529cc8 commit 80a2745

File tree

8 files changed

+9
-13
lines changed

8 files changed

+9
-13
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ load(
112112

113113
swiftformat_pkg(
114114
name = "format",
115-
config = "//:.swiftformat",
116115
)
117116
```
118117

doc/rules_and_macros_overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Formats the Swift source files using `nicklockwood/SwiftFormat`.
3131
| Name | Description | Type | Mandatory | Default |
3232
| :------------- | :------------- | :------------- | :------------- | :------------- |
3333
| <a id="swiftformat_format-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
34-
| <a id="swiftformat_format-config"></a>config | A swiftformat config file. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
34+
| <a id="swiftformat_format-config"></a>config | A swiftformat config file. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | @//:.swiftformat |
3535
| <a id="swiftformat_format-output_suffix"></a>output_suffix | The suffix to add to the output filename. | String | optional | "_formatted" |
3636
| <a id="swiftformat_format-srcs"></a>srcs | The Swift source files to format. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
3737
| <a id="swiftformat_format-swift_version"></a>swift_version | The Swift version to be used by <code>swiftformat</code>. You probably want to add this to your config file instead of adding it here. | String | optional | "" |

examples/simple/BUILD.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@ swiftformat_update_all(
3939
# test that the formatted files are in the workspace directory and copies
4040
# the formatted files to the workspace directory.
4141
swiftformat_pkg(
42-
name = "format",
43-
config = "//:.swiftformat",
42+
name = "swiftformat",
4443
)

examples/simple/Foo/BUILD.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ swift_library(
99
)
1010

1111
swiftformat_pkg(
12-
name = "format",
13-
config = "//:.swiftformat",
12+
name = "swiftformat",
1413
)

examples/swift_rule_helpers/Sources/App/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ load(
77
swiftformat_binary(
88
name = "simple",
99
srcs = ["main.swift"],
10-
swiftformat_config = "//:.swiftformat",
1110
visibility = ["//:__subpackages__"],
1211
deps = [
1312
"//Sources/Foo",

examples/swift_rule_helpers/Sources/Foo/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ swiftformat_library(
77
name = "Foo",
88
srcs = glob(["*.swift"]),
99
module_name = "Foo",
10-
swiftformat_config = "//:.swiftformat",
1110
visibility = ["//:__subpackages__"],
1211
)

examples/swift_rule_helpers/Tests/FooTests/MessageTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import XCTest
33

44
class MessageTests: XCTestCase {
5-
func test_init() throws {
6-
let value = "hello"
7-
let msg = Messsage(value = value)
8-
XCTAssertEqual(msg.value, value)
9-
}
5+
func test_init() throws {
6+
let value = "hello"
7+
let msg = Messsage(value = value)
8+
XCTAssertEqual(msg.value, value)
9+
}
1010
}

swiftformat/internal/swiftformat_format.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ to your config file instead of adding it here.\
6060
"config": attr.label(
6161
allow_single_file = True,
6262
doc = "A swiftformat config file.",
63+
default = "@//:.swiftformat",
6364
),
6465
"output_suffix": attr.string(
6566
default = "_formatted",

0 commit comments

Comments
 (0)