Skip to content

Commit

Permalink
Set default value for config attribute of swiftformat_format (#14)
Browse files Browse the repository at this point in the history
Set default value for the swiftformat config to be `@//:.swiftformat`.
  • Loading branch information
cgrindel authored Oct 14, 2021
1 parent 6529cc8 commit 80a2745
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ load(

swiftformat_pkg(
name = "format",
config = "//:.swiftformat",
)
```

Expand Down
2 changes: 1 addition & 1 deletion doc/rules_and_macros_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Formats the Swift source files using `nicklockwood/SwiftFormat`.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <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 | |
| <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 |
| <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 |
| <a id="swiftformat_format-output_suffix"></a>output_suffix | The suffix to add to the output filename. | String | optional | "_formatted" |
| <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 | |
| <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 | "" |
Expand Down
3 changes: 1 addition & 2 deletions examples/simple/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@ swiftformat_update_all(
# test that the formatted files are in the workspace directory and copies
# the formatted files to the workspace directory.
swiftformat_pkg(
name = "format",
config = "//:.swiftformat",
name = "swiftformat",
)
3 changes: 1 addition & 2 deletions examples/simple/Foo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ swift_library(
)

swiftformat_pkg(
name = "format",
config = "//:.swiftformat",
name = "swiftformat",
)
1 change: 0 additions & 1 deletion examples/swift_rule_helpers/Sources/App/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ load(
swiftformat_binary(
name = "simple",
srcs = ["main.swift"],
swiftformat_config = "//:.swiftformat",
visibility = ["//:__subpackages__"],
deps = [
"//Sources/Foo",
Expand Down
1 change: 0 additions & 1 deletion examples/swift_rule_helpers/Sources/Foo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ swiftformat_library(
name = "Foo",
srcs = glob(["*.swift"]),
module_name = "Foo",
swiftformat_config = "//:.swiftformat",
visibility = ["//:__subpackages__"],
)
10 changes: 5 additions & 5 deletions examples/swift_rule_helpers/Tests/FooTests/MessageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import XCTest

class MessageTests: XCTestCase {
func test_init() throws {
let value = "hello"
let msg = Messsage(value = value)
XCTAssertEqual(msg.value, value)
}
func test_init() throws {
let value = "hello"
let msg = Messsage(value = value)
XCTAssertEqual(msg.value, value)
}
}
1 change: 1 addition & 0 deletions swiftformat/internal/swiftformat_format.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ to your config file instead of adding it here.\
"config": attr.label(
allow_single_file = True,
doc = "A swiftformat config file.",
default = "@//:.swiftformat",
),
"output_suffix": attr.string(
default = "_formatted",
Expand Down

0 comments on commit 80a2745

Please sign in to comment.