diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 9bacea6..11abdc3 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -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 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index c81dc69..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,3 +0,0 @@ -Airbnb has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full Code of Conduct text](https://airbnb.io/codeofconduct/) so that you can understand what actions will and will not be tolerated. Report violations to the maintainers of this project or to [opensource-conduct@airbnb.com](mailto:opensource-conduct@airbnb.com). - -Reports sent to [opensource-conduct@airbnb.com](mailto:opensource-conduct@airbnb.com) are received by Airbnb's open source code of conduct moderation team, which is composed of Airbnb employees. All communications are private and confidential. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 3799cbc..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,35 +0,0 @@ -# Contributing - -To contribute a new style rule first fork the repo and create your branch from `master`. Then open a PR and propose the rule following the structure below. - -If you have an idea that's not completely fleshed out, please [open an issue](https://github.com/airbnb/swift/issues/new) to discuss. - -## Structure of a new rule: - -At minimum every rule should contain: - -1. A permalink to reference easily. -1. A short description. -1. A link to the appropriate [SwiftLint](https://github.com/realm/SwiftLint) / [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) rule. -1. _(optional)_ A "Why?" section describing the reasoning behind the rule. -1. A code example describing the incorrect and correct behaviours. - -#### Example: - -* (link) -**This is the description of the rule.** [![SwiftLint: some_rule](https://img.shields.io/badge/SwiftLint-some__rule-007A87.svg)](https://github.com/realm/SwiftLint/blob/master/Rules.md#some_rule) [![SwiftFormat: some_rule](https://img.shields.io/badge/SwiftFormat-some__rule-7B0051.svg)](https://github.com/nicklockwood/SwiftFormat#rules) - -
- - #### Why? - This is an explanation of why this rule is needed. - - ```swift - // WRONG - func someIncorrectCode {} - - // GOOD - func someGoodCode {} - ``` - -
diff --git a/LICENSE.md b/LICENSE.md index 69d80c0..1373b9b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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 diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3f8ab20..0000000 --- a/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,9 +0,0 @@ -#### Summary - - - -#### Reasoning - - - -_Please react with 👍/👎 if you agree or disagree with this proposal._ diff --git a/Package.swift b/Package.swift index a733512..1608828 100644 --- a/Package.swift +++ b/Package.swift @@ -2,7 +2,7 @@ import PackageDescription let package = Package( - name: "AirbnbSwift", + name: "RakuyoSwift", platforms: [.macOS(.v10_13)], products: [ .plugin(name: "FormatSwift", targets: ["FormatSwift"]), @@ -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", diff --git a/Plugins/FormatSwift/Plugin.swift b/Plugins/FormatSwift/Plugin.swift index 9d03c41..6bd31f4 100644 --- a/Plugins/FormatSwift/Plugin.swift +++ b/Plugins/FormatSwift/Plugin.swift @@ -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], @@ -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, @@ -69,7 +69,7 @@ struct AirbnbSwiftFormatPlugin { // MARK: CommandPlugin -extension AirbnbSwiftFormatPlugin: CommandPlugin { +extension RakuyoSwiftFormatPlugin: CommandPlugin { // MARK: Internal @@ -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) diff --git a/README.md b/README.md index fc97429..88e79de 100644 --- a/README.md +++ b/README.md @@ -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) @@ -100,7 +100,7 @@ _You can enable the following settings in Xcode by running [this script](resourc -* (link) **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) +* (link) **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) * (link) **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) @@ -692,39 +692,35 @@ _You can enable the following settings in Xcode by running [this script](resourc -* (link) **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) +* (link) **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)
```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] @@ -868,7 +864,7 @@ _You can enable the following settings in Xcode by running [this script](resourc ] ``` -* (link) [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) +* (link) [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)
diff --git a/Sources/AirbnbSwiftFormatTool/Command.swift b/Sources/RakuyoSwiftFormatTool/Command.swift similarity index 93% rename from Sources/AirbnbSwiftFormatTool/Command.swift rename to Sources/RakuyoSwiftFormatTool/Command.swift index d829011..f152f3b 100644 --- a/Sources/AirbnbSwiftFormatTool/Command.swift +++ b/Sources/RakuyoSwiftFormatTool/Command.swift @@ -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 diff --git a/Sources/AirbnbSwiftFormatTool/AirbnbSwiftFormatTool.swift b/Sources/RakuyoSwiftFormatTool/RakuyoSwiftFormatTool.swift similarity index 94% rename from Sources/AirbnbSwiftFormatTool/AirbnbSwiftFormatTool.swift rename to Sources/RakuyoSwiftFormatTool/RakuyoSwiftFormatTool.swift index 132751d..11c6fe1 100644 --- a/Sources/AirbnbSwiftFormatTool/AirbnbSwiftFormatTool.swift +++ b/Sources/RakuyoSwiftFormatTool/RakuyoSwiftFormatTool.swift @@ -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 @@ -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")! @@ -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) } } diff --git a/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat b/Sources/RakuyoSwiftFormatTool/rakuyo.swiftformat similarity index 98% rename from Sources/AirbnbSwiftFormatTool/airbnb.swiftformat rename to Sources/RakuyoSwiftFormatTool/rakuyo.swiftformat index ce2fa62..5caec44 100644 --- a/Sources/AirbnbSwiftFormatTool/airbnb.swiftformat +++ b/Sources/RakuyoSwiftFormatTool/rakuyo.swiftformat @@ -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 @@ -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 diff --git a/Sources/AirbnbSwiftFormatTool/swiftlint.yml b/Sources/RakuyoSwiftFormatTool/swiftlint.yml similarity index 100% rename from Sources/AirbnbSwiftFormatTool/swiftlint.yml rename to Sources/RakuyoSwiftFormatTool/swiftlint.yml diff --git a/Tests/AirbnbSwiftFormatToolTests/AirbnbSwiftFormatToolTests.swift b/Tests/RakuyoSwiftFormatToolTests/RakuyoSwiftFormatToolTests.swift similarity index 94% rename from Tests/AirbnbSwiftFormatToolTests/AirbnbSwiftFormatToolTests.swift rename to Tests/RakuyoSwiftFormatToolTests/RakuyoSwiftFormatToolTests.swift index 52bc6ca..df0820f 100644 --- a/Tests/AirbnbSwiftFormatToolTests/AirbnbSwiftFormatToolTests.swift +++ b/Tests/RakuyoSwiftFormatToolTests/RakuyoSwiftFormatToolTests.swift @@ -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 @@ -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 ?? [])) @@ -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)? diff --git a/resources/xcode_settings.bash b/resources/xcode_settings.bash index 1a5ef0b..6216585 100755 --- a/resources/xcode_settings.bash +++ b/resources/xcode_settings.bash @@ -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