Skip to content

Commit

Permalink
Update to the latest version of SwiftFormat (#250)
Browse files Browse the repository at this point in the history
* Update to the latest version of SwiftFormat

This fixes inconsistencies in argument and parameter formatting that we previously had.

* Fix function length in `Path.swift`

* Fix linter warnings

* More formatting cleanups

* Add `StrokeStyle.zero` in the `StaticHTML` module
  • Loading branch information
MaxDesiatov committed Aug 5, 2020
1 parent 88064fd commit c4c9eb5
Show file tree
Hide file tree
Showing 53 changed files with 1,192 additions and 677 deletions.
7 changes: 5 additions & 2 deletions .swiftformat
@@ -1,9 +1,12 @@
--indent 2
--indentcase false
--trimwhitespace always
--empty tuple
--voidtype tuple
--nospaceoperators ..<,...
--ifdef noindent
--stripunusedargs closure-only
--maxwidth 100
--wraparguments before-first
--funcattributes prev-line
--disable andOperator
--swiftversion 5.2
--swiftversion 5.3
1 change: 1 addition & 0 deletions .swiftlint.yml
Expand Up @@ -9,6 +9,7 @@ disabled_rules:
- type_name
- todo
- large_tuple
- opening_brace

line_length: 100

Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
@@ -1,4 +1,7 @@
{
"editor.formatOnSave": true,
"licenser.author": "Tokamak contributors"
"licenser.author": "Tokamak contributors",
"cSpell.words": [
"Tokamak"
]
}
24 changes: 12 additions & 12 deletions README.md
Expand Up @@ -200,18 +200,18 @@ appreciated and helps in maintaining the project.

### Coding Style

This project uses [SwiftFormat](https://github.com/nicklockwood/SwiftFormat)
and [SwiftLint](https://github.com/realm/SwiftLint) to
enforce formatting and coding style. We encourage you to run SwiftFormat within
a local clone of the repository in whatever way works best for you either
manually or automatically via an [Xcode
extension](https://github.com/nicklockwood/SwiftFormat#xcode-source-editor-extension),
[build phase](https://github.com/nicklockwood/SwiftFormat#xcode-build-phase) or
[git pre-commit
hook](https://github.com/nicklockwood/SwiftFormat#git-pre-commit-hook) etc.

To guarantee that these tools run before you commit your changes on macOS, you're encouraged
to run this once to set up the [pre-commit](https://pre-commit.com/) hook:
This project uses [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) and
[SwiftLint](https://github.com/realm/SwiftLint) to enforce formatting and coding style. SwiftFormat
0.45.3 and SwiftLint 0.39.2 or later versions are recommended. We encourage you to run SwiftFormat
and SwiftLint within a local clone of the repository in whatever way works best for you. You can do
that either manually, or automatically with VSCode extensions for
[SwiftFormat](https://github.com/vknabel/vscode-swiftformat) and
[SwiftLint](https://github.com/vknabel/vscode-swiftlint) respectively, or with the [Xcode
extension](https://github.com/nicklockwood/SwiftFormat#xcode-source-editor-extension), or [build
phase](https://github.com/nicklockwood/SwiftFormat#xcode-build-phase).

To guarantee that these tools run before you commit your changes on macOS, you're encouraged to run
this once to set up the [pre-commit](https://pre-commit.com/) hook:

```
brew bundle # installs SwiftLint, SwiftFormat and pre-commit
Expand Down
62 changes: 30 additions & 32 deletions Sources/TokamakCore/App/AppStorage.swift
Expand Up @@ -54,50 +54,49 @@ import CombineShim
extension AppStorage: ObservedProperty {}

extension AppStorage {
public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil) where Value == Bool {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Bool
{
defaultValue = wrappedValue
self.key = key
provider = store
self.store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) }
}

public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil) where Value == Int {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Int
{
defaultValue = wrappedValue
self.key = key
provider = store
self.store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) }
}

public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil) where Value == Double {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Double
{
defaultValue = wrappedValue
self.key = key
provider = store
self.store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) }
}

public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil) where Value == String {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == String
{
defaultValue = wrappedValue
self.key = key
provider = store
self.store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) }
}

public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil)
where Value: RawRepresentable, Value.RawValue == Int {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value: RawRepresentable, Value.RawValue == Int
{
defaultValue = wrappedValue
self.key = key
provider = store
Expand All @@ -110,10 +109,9 @@ extension AppStorage {
}
}

public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil)
where Value: RawRepresentable, Value.RawValue == String {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value: RawRepresentable, Value.RawValue == String
{
defaultValue = wrappedValue
self.key = key
provider = store
Expand All @@ -128,39 +126,39 @@ extension AppStorage {
}

extension AppStorage where Value: ExpressibleByNilLiteral {
public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil) where Value == Bool? {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Bool?
{
defaultValue = wrappedValue
self.key = key
provider = store
self.store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) }
}

public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil) where Value == Int? {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Int?
{
defaultValue = wrappedValue
self.key = key
provider = store
self.store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) }
}

public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil) where Value == Double? {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == Double?
{
defaultValue = wrappedValue
self.key = key
provider = store
self.store = { $0.store(key: $1, value: $2) }
read = { $0.read(key: $1) }
}

public init(wrappedValue: Value,
_ key: String,
store: _StorageProvider? = nil) where Value == String? {
public init(wrappedValue: Value, _ key: String, store: _StorageProvider? = nil)
where Value == String?
{
defaultValue = wrappedValue
self.key = key
provider = store
Expand Down

0 comments on commit c4c9eb5

Please sign in to comment.