Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change wrapAttributes format #267

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Setup
description: Setup the airbnb/swift CI Environment
description: Setup the rakuyo/swift CI Environment
inputs:
xcode:
description: The version of Xcode to select
Expand Down
3 changes: 0 additions & 3 deletions CODE_OF_CONDUCT.md

This file was deleted.

35 changes: 0 additions & 35 deletions CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2012 Airbnb
Copyright (c) 2012 Airbnb And 2024 Rakuyo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 0 additions & 9 deletions PULL_REQUEST_TEMPLATE.md

This file was deleted.

14 changes: 7 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import PackageDescription

let package = Package(
name: "AirbnbSwift",
name: "RakuyoSwift",
platforms: [.macOS(.v10_13)],
products: [
.plugin(name: "FormatSwift", targets: ["FormatSwift"]),
Expand All @@ -16,29 +16,29 @@ let package = Package(
capability: .command(
intent: .custom(
verb: "format",
description: "Formats Swift source files according to the Airbnb Swift Style Guide"),
description: "Formats Swift source files according to the Rakuyo Swift Style Guide"),
permissions: [
.writeToPackageDirectory(reason: "Format Swift source files"),
]),
dependencies: [
"AirbnbSwiftFormatTool",
"RakuyoSwiftFormatTool",
"SwiftFormat",
"SwiftLintBinary",
]),

.executableTarget(
name: "AirbnbSwiftFormatTool",
name: "RakuyoSwiftFormatTool",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
resources: [
.process("airbnb.swiftformat"),
.process("Rakuyo.swiftformat"),
.process("swiftlint.yml"),
]),

.testTarget(
name: "AirbnbSwiftFormatToolTests",
dependencies: ["AirbnbSwiftFormatTool"]),
name: "RakuyoSwiftFormatToolTests",
dependencies: ["RakuyoSwiftFormatTool"]),

.binaryTarget(
name: "SwiftFormat",
Expand Down
16 changes: 8 additions & 8 deletions Plugins/FormatSwift/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import PackagePlugin
import XcodeProjectPlugin
#endif

// MARK: - AirbnbSwiftFormatPlugin
// MARK: - RakuyoSwiftFormatPlugin

/// A Swift Package Manager `CommandPlugin` and `XcodeCommandPlugin` that executes
/// `AirbnbSwiftFormatTool` to format source code in Swift package targets according
/// to the Airbnb Swift Style Guide.
/// `RakuyoSwiftFormatTool` to format source code in Swift package targets according
/// to the Rakuyo Swift Style Guide.
@main
struct AirbnbSwiftFormatPlugin {
struct RakuyoSwiftFormatPlugin {

/// Calls the `AirbnbSwiftFormatTool` executable with the given arguments
/// Calls the `RakuyoSwiftFormatTool` executable with the given arguments
func performCommand(
context: CommandContext,
inputPaths: [String],
Expand All @@ -29,7 +29,7 @@ struct AirbnbSwiftFormatPlugin {
})
}

let launchPath = try context.tool(named: "AirbnbSwiftFormatTool").path.string
let launchPath = try context.tool(named: "RakuyoSwiftFormatTool").path.string
let arguments = inputPaths + [
"--swift-format-path",
try context.tool(named: "swiftformat").path.string,
Expand Down Expand Up @@ -69,7 +69,7 @@ struct AirbnbSwiftFormatPlugin {

// MARK: CommandPlugin

extension AirbnbSwiftFormatPlugin: CommandPlugin {
extension RakuyoSwiftFormatPlugin: CommandPlugin {

// MARK: Internal

Expand Down Expand Up @@ -136,7 +136,7 @@ extension AirbnbSwiftFormatPlugin: CommandPlugin {
}

#if canImport(XcodeProjectPlugin)
extension AirbnbSwiftFormatPlugin: XcodeCommandPlugin {
extension RakuyoSwiftFormatPlugin: XcodeCommandPlugin {

func performCommand(context: XcodePluginContext, arguments: [String]) throws {
var argumentExtractor = ArgumentExtractor(arguments)
Expand Down
30 changes: 13 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Airbnb Swift Style Guide
# Rakuyo Swift Style Guide

[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fairbnb%2Fswift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/airbnb/swift) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fairbnb%2Fswift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/airbnb/swift)

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

</details>

* <a id='spaces-over-tabs'></a>(<a href='#spaces-over-tabs'>link</a>) **Use 2 spaces to indent lines.** [![SwiftFormat: indent](https://img.shields.io/badge/SwiftFormat-indent-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#indent)
* <a id='spaces-over-tabs'></a>(<a href='#spaces-over-tabs'>link</a>) **Use 4 spaces to indent lines.** [![SwiftFormat: indent](https://img.shields.io/badge/SwiftFormat-indent-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#indent)

* <a id='trailing-whitespace'></a>(<a href='#trailing-whitespace'>link</a>) **Trim trailing whitespace in all lines.** [![SwiftFormat: trailingSpace](https://img.shields.io/badge/SwiftFormat-trailingSpace-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#trailingSpace)

Expand Down Expand Up @@ -692,39 +692,35 @@ _You can enable the following settings in Xcode by running [this script](resourc

</details>

* <a id='simple-stored-property-attributes-on-same-line'></a>(<a href='#simple-stored-property-attributes-on-same-line'>link</a>) **Place simple attributes for stored properties on the same line as the rest of the declaration**. Complex attributes with named arguments, or more than one unnamed argument, should be placed on the previous line. [![SwiftFormat: wrapAttributes](https://img.shields.io/badge/SwiftFormat-wrapAttributes-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#wrapAttributes)
* <a id='simple-stored-property-attributes-on-same-line'></a>(<a href='#simple-stored-property-attributes-on-same-line'>link</a>) **Place attributes for properties on the previous line.**. whether it's complicated or not. [![SwiftFormat: wrapAttributes](https://img.shields.io/badge/SwiftFormat-wrapAttributes-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#wrapAttributes)

<details>

```swift
// WRONG. These simple property wrappers should be written on the same line as the declaration.
struct SpaceshipDashboardView {

@State
private var warpDriveEnabled: Bool

@ObservedObject
private var lifeSupportService: LifeSupportService
@State private var warpDriveEnabled: Bool

@Environment(\.controlPanelStyle)
private var controlPanelStyle
@ObservedObject private var lifeSupportService: LifeSupportService

@Environment(\.controlPanelStyle) private var controlPanelStyle
}

// RIGHT
struct SpaceshipDashboardView {

@State private var warpDriveEnabled: Bool

@ObservedObject private var lifeSupportService: LifeSupportService
@State
private var warpDriveEnabled: Bool

@Environment(\.controlPanelStyle) private var controlPanelStyle
@ObservedObject
private var lifeSupportService: LifeSupportService

@Environment(\.controlPanelStyle)
private var controlPanelStyle
}
```

```swift
// WRONG. These complex attached macros should be written on the previous line.
struct SolarSystemView {

@Query(sort: \.distance) var allPlanets: [Planet]
Expand Down Expand Up @@ -868,7 +864,7 @@ _You can enable the following settings in Xcode by running [this script](resourc
]
```

* <a id='long-typealias'></a>(<a href='#long-typealias'>link</a>) [Long](https://github.com/airbnb/swift#column-width) type aliases of protocol compositions should wrap before the `=` and before each individual `&`. [![SwiftFormat: wrapArguments](https://img.shields.io/badge/SwiftFormat-wrapArguments-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#wrapArguments)
* <a id='long-typealias'></a>(<a href='#long-typealias'>link</a>) [Long](https://github.com/RakuyoKit/swift#column-width) type aliases of protocol compositions should wrap before the `=` and before each individual `&`. [![SwiftFormat: wrapArguments](https://img.shields.io/badge/SwiftFormat-wrapArguments-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md#wrapArguments)

<details>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Created by Cal Stephens on 9/25/23.
// Copyright © 2023 Airbnb Inc. All rights reserved.

import Foundation

/// A single command line invocation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import ArgumentParser
import Foundation

// MARK: - AirbnbSwiftFormatTool
// MARK: - RakuyoSwiftFormatTool

/// A command line tool that formats the given directories using SwiftFormat and SwiftLint,
/// based on the Airbnb Swift Style Guide
/// based on the Rakuyo Swift Style Guide
@main
struct AirbnbSwiftFormatTool: ParsableCommand {
struct RakuyoSwiftFormatTool: ParsableCommand {

// MARK: Internal

Expand All @@ -32,7 +32,7 @@ struct AirbnbSwiftFormatTool: ParsableCommand {
var log = false

@Option(help: "The absolute path to the SwiftFormat config file")
var swiftFormatConfig = Bundle.module.path(forResource: "airbnb", ofType: "swiftformat")!
var swiftFormatConfig = Bundle.module.path(forResource: "rakuyo", ofType: "swiftformat")!

@Option(help: "The absolute path to the SwiftLint config file")
var swiftLintConfig = Bundle.module.path(forResource: "swiftlint", ofType: "yml")!
Expand Down Expand Up @@ -145,7 +145,7 @@ struct AirbnbSwiftFormatTool: ParsableCommand {

private func log(_ string: String) {
// swiftlint:disable:next no_direct_standard_out_logs
print("[AirbnbSwiftFormatTool]", string)
print("[RakuyoSwiftFormatTool]", string)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
--importgrouping testable-bottom # sortedImports
--commas always # trailingCommas
--trimwhitespace always # trailingSpace
--indent 2 #indent
--indent 4 #indent
--ifdef no-indent #indent
--indentstrings true #indent
--wraparguments before-first # wrapArguments
Expand All @@ -20,7 +20,7 @@
--wraptypealiases before-first # wrapArguments
--funcattributes prev-line # wrapAttributes
--computedvarattrs prev-line # wrapAttributes
--storedvarattrs same-line # wrapAttributes
--storedvarattrs prev-line # wrapAttributes
--complexattrs prev-line # wrapAttributes
--typeattributes prev-line # wrapAttributes
--wrapternary before-operators # wrap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// Created by Cal Stephens on 9/25/23.
// Copyright © 2023 Airbnb Inc. All rights reserved.

import ArgumentParser
import XCTest

@testable import AirbnbSwiftFormatTool
@testable import RakuyoSwiftFormatTool

// MARK: - AirbnbSwiftFormatToolTest
// MARK: - RakuyoSwiftFormatToolTest

final class AirbnbSwiftFormatToolTest: XCTestCase {
final class RakuyoSwiftFormatToolTest: XCTestCase {

// MARK: Internal

Expand Down Expand Up @@ -234,17 +231,17 @@ final class AirbnbSwiftFormatToolTest: XCTestCase {

// MARK: Private

/// Runs `AirbnbSwiftFormatTool` with the `Command` calls mocked using the given mocks
/// Runs `RakuyoSwiftFormatTool` with the `Command` calls mocked using the given mocks
private func runFormatTool(arguments: [String]? = nil, with mocks: MockCommands) -> Error? {
let existingRunCommandImplementation = Command.runCommand

Command.runCommand = mocks.mockRunCommand(_:)
defer { Command.runCommand = existingRunCommandImplementation }

let formatTool = try! AirbnbSwiftFormatTool.parse([
let formatTool = try! RakuyoSwiftFormatTool.parse([
"Sources",
"--swift-format-path",
"airbnb.swiftformat",
"rakuyo.swiftformat",
"--swift-lint-path",
"swiftlint.yml",
] + (arguments ?? []))
Expand All @@ -261,7 +258,7 @@ final class AirbnbSwiftFormatToolTest: XCTestCase {

// MARK: - MockCommands

/// Mock implementations of the commands ran by `AirbnbSwiftFormatTool`
/// Mock implementations of the commands ran by `RakuyoSwiftFormatTool`
struct MockCommands {
var swiftFormat: (() -> Int32)?
var swiftLint: (() -> Int32)?
Expand Down
4 changes: 2 additions & 2 deletions resources/xcode_settings.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defaults write com.apple.dt.Xcode AutomaticallyCheckSpellingWhileTyping -bool YE
defaults write com.apple.dt.Xcode DVTTextEditorTrimTrailingWhitespace -bool YES
defaults write com.apple.dt.Xcode DVTTextEditorTrimWhitespaceOnlyLines -bool YES

defaults write com.apple.dt.Xcode DVTTextIndentTabWidth -int 2
defaults write com.apple.dt.Xcode DVTTextIndentWidth -int 2
defaults write com.apple.dt.Xcode DVTTextIndentTabWidth -int 4
defaults write com.apple.dt.Xcode DVTTextIndentWidth -int 4

defaults write com.apple.dt.Xcode DVTTextPageGuideLocation -int 100
Loading