Zenn
🛠️

swift-format の Configuration

2021/06/22に公開
2
1

検証条件

  • Xcode 16.3 build tool chain に含まれる swift-format (ver main)
  • lineLengthを 1000 に設定してなるべくワンラインでコードを書いて検証
  • 改行状態が必要な場合はrespectsExistingLineBreaksを true にして検証

Command Line Configuration

version(number)

Configuration file のバージョン。今は常に1。

lineLength(number)

一行あたりの最長文字数。これを超えると改行される。基本的にはこれが最も強力なルールになる。キリのいいところで改行が入る。

  • 変数宣言の頭
  • =での代入の直後
  • クロージャーや関数の引数
  • チェーンメソッド
  • 開き中括弧{の直後
  • 閉じ中括弧}

など。

indentation(object)

一段階インデントする時の空白の種類と幅。spacestabsのどちらか一方のみ。

  • spaces(number): インデントは指定された個数のスペース
  • tabs(number): インデントは指定された個数のタブ

tabWidth(number)

一つのタブに相当するとみなされるスペースの数。タブをインデントに指定したときに有効。

maximumBlankLines(number)

連続した空行の最大数。

spacesBeforeEndOfLineComments (number)

空行でない行の最後トークンと//で始まるコメントの間のスペースの数。

var value: Int = 0  // This is a variable.

例えば上記の場合は0//の間のスペースのこと。

respectsExistingLineBreaks(boolean)

ソースコード中の既存の改行を尊重するかどうか。

before
if value1 < value2 {
} else if value2 < value3 {
} else {
}

if value1 < value2 {

} else if value2 < value3 {

} else {

}
after(false)
if value1 < value2 {} else if value2 < value3 {} else {}

if value1 < value2 {

} else if value2 < value3 {

} else {

}

true の場合は before のまんま。

lineBreakBeforeControlFlowKeywords(boolean)

elsecatchの直前の改行動作。true だとキーワードの前で改行が入る。

false
if value1 < value2 { } else if value2 < value3 { } else { }

do { let _ = try something() } catch { print(error) }
true
if value1 < value2 {
}
else if value2 < value3 {
}
else {
}

do { let _ = try something() }
catch { print(error) }

lineBreakBeforeEachArgument(boolean)

変数や引数の改行動作。変数宣言や関数の引数定義でlineLengthを超えた場合改行されるが、そのときの改行の仕方が変わる。true だと変数や引数ごとに改行される。false だとlineLengthを超えた場合のみ改行される。すなわち、lineLengthが非常に大きい数値だと機能しない。

lineLength=50のときの例

before
func arguments(a: String, b: String, c: String, d: String) -> Bool { return false }
after(false)
func arguments(
    a: String, b: String, c: String, d: String
) -> Bool { return false }
after(true)
func arguments(
    a: String,
    b: String,
    c: String,
    d: String
) -> Bool { return false }

lineBreakBeforeEachGenericRequirement(boolean)

ジェネリックキーワードの改行動作。lineLengthを超えた場合ジェネリックキーワードの区切りに改行が入るが、その時の改行の仕方が変わる。true にするとジェネリックキーワードごとに改行される。false だとlineLengthを超えた場合のみ改行される。すなわち、lineLengthが非常に大きい数値だと機能しない。

lineLength=50のときの例

before
class MyClass<S, T, U, W> where S: Collection, T: Equatable, U: Hashable, W: AnyObject { }
after(false)
class MyClass<S, T, U, W>
where
    S: Collection, T: Equatable, U: Hashable,
    W: AnyObject
{}
after(true)
class MyClass<S, T, U, W>
where
    S: Collection,
    T: Equatable,
    U: Hashable,
    W: AnyObject
{}

lineBreakBetweenDeclarationAttributes (boolean)

属性(Attributes)を複数付与するときの改行動作。true にすると属性ごとに改行される。false だとlineLengthを超えた場合のみ改行される。すなわち、lineLengthが非常に大きい数値だと機能しない。

before
@available(*, unavailable) @discardableResult @MainActor
func hoge() -> Bool { true }
after(true)
@available(*, unavailable)
@discardableResult
@MainActor
func hoge() -> Bool { true }

prioritizeKeepingFunctionOutputTogether(boolean)

関数の戻り値の定義において、閉じ括弧)とくっつけることを優先するかどうか。

lineLength=34(つまり->までの長さ)のときの例

before
func hoge(_ value1: Int) throws -> Int { return 0 }
after(false)
func hoge(_ value1: Int) throws
    -> Int
{ return 0 }
after(true)
func hoge(
    _ value1: Int
) throws -> Int { return 0 } // )とその後のthrows -> Intがひとまとまりになっている。

indentConditionalCompilationBlocks(boolean)

条件付きコンパイルのブロックをインデントするかどうか。

false
#if someCondition
let a = 123
#else
let c = 456
#endif
true
#if someCondition
    let a = 123
#else
    let c = 456
#endif

lineBreakAroundMultilineExpressionChainComponents(boolean)

lineLengthを超えた場合、キリのいいところで改行が入るが、チェーンメソッドにおいて改行した結果複数行に跨がる場合は、チェーンメソッド開始の.のところで改行するというフラグ。複数行に跨がることがない場合は無視される。癖がすごいんじゃ。下の例では.mapの改行のされ方に注目して欲しい。

lineLength=45のときの例

before
let hoge = "abc,def,ghi"
hoge.components(separatedBy: ",").map({ (item) -> String in item.uppercased() }).filter { $0.contains("E") }.joined().forEach { (char) in if char < "e" { print(char) } else { print("-")} }
after(false)
let hoge = "abc,def,ghi"
hoge.components(separatedBy: ",").map({
    (item) -> String in item.uppercased()
}).filter { $0.contains("E") }.joined()
    .forEach { (char) in
        if char < "e" {
            print(char)
        } else {
            print("-")
        }
    }
after(true)
let hoge = "abc,def,ghi"
hoge.components(separatedBy: ",")
    .map({ (item) -> String in
        item.uppercased()
    })
    .filter { $0.contains("E") }.joined()
    .forEach { (char) in
        if char < "e" {
            print(char)
        } else {
            print("-")
        }
    }

indentSwitchCaseLabels(boolean)

switch 文の case で段落下げをするかどうか。

false
switch value {
case 100: print()
case 200 ..< 300: print()
case 300: print()
default: break
}
true
switch value {
    case 100: print()
    case 200 ..< 300: print()
    case 300: print()
    default: break
}

fileScopedDeclarationPrivacy(object)

rulesFileScopedDeclarationPrivacyを true に指定しているときに有効。

  • accessLevel(string): privateまたはfileprivateを指定する。privateを指定すると、fileprivateprivateになる。fileprivateを指定すると、privatefileprivateになる。

spacesAroundRangeFormationOperators(boolean)

Range の..<...の前後にスペースを入れるかどうか。

before
_ = (0..<5).map(\.self)
_ = (0 ..< 5).map(\.self)
_ = (0...5).map(\.self)
_ = (0 ... 5).map(\.self)
after(false)
_ = (0..<5).map(\.self)
_ = (0..<5).map(\.self)
_ = (0...5).map(\.self)
_ = (0...5).map(\.self)
after(true)
_ = (0 ..< 5).map(\.self)
_ = (0 ..< 5).map(\.self)
_ = (0 ... 5).map(\.self)
_ = (0 ... 5).map(\.self)

noAssignmentInExpressions(object)

Lint で有効。
rulesNoAssignmentInExpressionsを true に指定しているときに有効。

原則、代入式(a = b)を Void 値を期待するコンテキストで使用することは禁止されているらしい。例えば、以下のような実装はコンパイルは通るがよくないっぽい。

func hoge() {
    return _ = Int()
}

上記の実装は swift-format でフォーマットをかけると以下のように変換される。

func hoge() {
    _ = Int()
    return
}

noAssignmentInExpressionsは特定の関数の引数として代入式を渡すことを許す指定ができる。デフォルトではXCTAssertNoThrowが許されている。

具体的には

func Hoge<T>(_ expression: @autoclosure () throws -> T) {}

という関数があった場合、引数に代入式を渡すことができる。デフォルトだと

Hoge({ _ = Int() })
Hoge { _ = Int() }

の2つは警告が出ないが、

Hoge(_ = Int())

だと警告が出る。noAssignmentInExpressionsallowedFunctionsに関数名を指定すると、この警告が出ないようになる。

multiElementCollectionTrailingCommas(boolean)

配列を要素ごとに改行して記述する場合に、最後の要素の末尾にカンマをつけるかどうか。

before
let array: [String] = [
    "apple",
    "banana",
    "cherry"
]

let array: [String] = [
    "apple",
    "banana",
    "cherry",
]
after(false)
let array: [String] = [
    "apple",
    "banana",
    "cherry"
]

let array: [String] = [
    "apple",
    "banana",
    "cherry"
]
after(true)
let array: [String] = [
    "apple",
    "banana",
    "cherry",
]

let array: [String] = [
    "apple",
    "banana",
    "cherry",
]

reflowMultilineStringLiterals(boolean)

複数行の文字列リテラルをどのようにリフローするかを決定する。

そもそも文字列リテラルでは、文字列としては改行したくないけどソースコード上は長文を途中で改行したい時にリフローができる。下記の末尾のバックスラッシュがそれ。

"""
Lorem ipsum dolor sit amet,\
 consectetur adipiscing elit,\
 sed do eiusmod tempor incididunt\
 ut labore et dolore magna aliqua.
"""

neverだとリフローさせない。
onlyLinesOverLengthだとlineLengthを超えた場合のみリフローされる。
alwaysだとlineLengthに合わせて自動で適切にリフローを施す。

Rules

全て指定は boolean。

AllPublicDeclarationsHaveDocumentation

Lint で有効。
true の場合、publicまたはopenな宣言の直前にコメントがない場合に警告が出る。

AlwaysUseLiteralForEmptyCollectionInit

配列の定義に関して、[<Type>]()の使用を禁止し、可能であれば[]に修正する。

before
let array: [String] = [String]()

let array = [String]()

func hoge(array: [String] = [String]()) {}
after(true)
let array: [String] = []

let array: [String] = []

func hoge(array: [String] = []) {}

AlwaysUseLowerCamelCase

Lint で有効。
true の場合、ローワーキャメルケースでない宣言があると警告が出る。

func GetValue() -> Int { } // GetValueはローワーキャメルケースじゃないよ

AmbiguousTrailingClosureOverload

Lint で有効。
true の場合、曖昧なクロージャーのオーバーロードを発見した場合に警告が出る。

// 下の三つは曖昧で区別がつかないよ
func hoge(mad: () -> Int) {}
func hoge(bad: (Bool) -> Bool) {}
func hoge(sad: (String) -> Bool) {}

AvoidRetroactiveConformances

Lint で有効。
true の場合、@retroactiveを使用していると警告が出る。

BeginDocumentationCommentWithOneLineSummary

Lint で有効。
よくわかりませんが、コメントの書き方についての警告が出るみたいです。

DoNotUseSemicolons

true にすると命令の末尾のセミコロンを禁止して、改行が必要な場合は改行を挿入します。

before
var value1: Int = 0;
var value2: Int = 1
var value3: Int = 2; var value4: Int = 3; var value5: Int = 4
after(true)
var value1: Int = 0
var value2: Int = 1
var value3: Int = 2
var value4: Int = 3
var value5: Int = 4

DontRepeatTypeInStaticProperties

Lint で有効。
true にすると static や class で宣言されている変数名について型被りしてると警告が出る。

class UIColor {
    static let redColor: UIColor // redColor は冗長なので red を推奨
    class var blueColor: UIColor // blueColor は冗長なので blue を推奨
}

protocol Person {
    static let youngPerson: Person // youngPerson は冗長なので young を推奨
}

FileScopedDeclarationPrivacy

Command Line Configuration の fileScopedDeclarationPrivacy で記述。

FullyIndirectEnum

よくわかりませんが、indirect caseしかないときにindirect enumに書き換えるみたいです。

before
public enum Piyo {
    indirect case aaa(a: Piyo)
    indirect case bbb(bbb: Piyo)
}
after(true)
public indirect enum Piyo {
    case aaa(a: Piyo)
    case bbb(bbb: Piyo)
}

GroupNumericLiterals

true にすると数値をアンダースコアで分割して表記するようになる。

before
let a = 1234567890
let b = -1234567890
let c = 0x12345678
let d = -0x12345678
let e = 0b100101010110
let f = -0b100101010110
after(true)
let a = 1_234_567_890
let b = -1_234_567_890
let c = 0x1234_5678
let d = -0x1234_5678
let e = 0b1001_01010110
let f = -0b1001_01010110

IdentifiersMustBeASCII

Lint で有効。
true の場合、変数名や関数名などに ASCII 文字以外が含まれていると警告が出る。

letPattern: Int = 0 // △は禁止

NeverForceUnwrap

Lint で有効。
true の場合、オプショナルを強制アンラップしている箇所に警告が出る。

let a: String? = nil
let b = a! // 強制アンラップ禁止

let c: Int? = nil
let d = c as! Double // 強制案ラップ禁止

NeverUseForceTry

Lint で有効。
true の場合、強制 try している箇所に警告が出る。

func throwFunc() throws -> Int {
    throw NSError()
}
let result = try! throwFunc() // try!は禁止

NeverUseImplicitlyUnwrappedOptionals

Lint で有効。
true の場合、暗黙的アンラップ型の宣言箇所に警告が出る。

var num: Int! // 暗黙的アンラップ禁止
var str: String! = nil // 暗黙的アンラップ禁止
@IBOutlet var button: UIButton! // このパターンでは警告は出ない

NoAccessLevelOnExtensionDeclaration

true の場合、extension についている open 以外のアクセス修飾子を削除する。

before
open extension String {}
public extension String {}
internal extension String {}
fileprivate extension String {}
private extension String {}
after(true)
open extension String {}
extension String {}
extension String {}
extension String {}
extension String {}

NoAssignmentInExpressions

Command Line Configuration の noAssignmentInExpressions で記述。

NoBlockComments

Lint で有効。
true の場合、ブロックコメント/* */を禁止。

var num: /* IOByteCout is UInt64 */ IOByteCount = 0 // ブロックコメント禁止

/*  // ブロックコメント禁止
 This open source software is created by kyome.
*/

NoCasesWithOnlyFallthrough

true の場合、switch 文においてfallthroughだけしている case をなくす。

before
enum Type {
    case ready
    case start
    case pause
    case stop
}

var type = Type.ready
switch type {
case .ready:
    print("ready")
case .start:
    fallthrough
case .pause:
    fallthrough
case .stop:
    print("stop")
}
after(true)
// (省略)

switch type {
case .ready:
    print("ready")
case .start, .pause, .stop:
    print("stop")
}

NoEmptyLinesOpeningClosingBraces

開き括弧の後と閉じ括弧の前に空行を入れることを禁止する。
true の場合、不要な空行を取り除く。

before
let array = (0 ..< 5).map({

    $0.description

})
after(true)
let array = (0 ..< 5).map({
    $0.description
})

NoEmptyTrailingClosureParentheses

true の場合、Trailing Clousure の空括弧を取り除く。

before
DispatchQueue.main.async() {
    print("Hi")
}

func meu(_ callback: () -> Void) {
    callback()
}

meu() {
    print("Bye")
}
after(true)
DispatchQueue.main.async { // ()が取り除かれた
    print("Hi")
}

// (中略)

meu { // ()が取り除かれた
    print("Bye")
}

NoLabelsInCasePatterns

true の場合、Associated Value ありの case 文において、ラベルをなくす。

before
enum Type {
    case one(left: Int, right: Int)
}
var type = Type.one(left: 0, right: 1)

switch type {
case .one(left: let left, right: let right):
    print(left, right)
}
after(true)
// (中略)
switch type {
case .one(let left, let right):
    print(left, right)
}

NoLeadingUnderscores

Lint で有効。
true の場合、変数名の前にアンダースコアがついていると警告が出る。

let _foo = "foo" // _fooの_は取り除くこと
func _piyo() { } // _piyoの_は取り除くこと

NoParensAroundConditions

true の場合、条件式の前後の不要な括弧を取り除く。括弧が必要な場合は除かれない。

before
if (x) { }

guard (x), (y), (z == 3) else { }

while (x) { }

repeat {

} while(x)

switch (4) {
default: break
}
after(true)
if x {}

guard x, y, z == 3 else {}

while x {}

repeat {

} while x

switch 4 {
default: break
}

NoPlaygroundLiterals

Lint で有効。
#colorLiteral #fileLiteral #imageLiteral のような Playground Literals を使用していると警告が出る。

NoVoidReturnOnFunctionSignature

true の場合、Void を return する関数の-> Void-> ()を取り除く。クロージャーの定義など必要な場合は除かれない。

before
func foo() -> () { }

func test() -> Void { }
after(true)
func foo() { }

func test() { }
例外
func hoge(_ callback: () -> Void) { }

let hoge = { () -> Void in print("") }

OmitExplicitReturns

true の場合、関数やクロージャーで単一式を return している箇所の return を可能であれば省略する。
省略可能か判断がつかない場合は Lint の警告が出る。

before
func hoge() -> Int {
    return 0
}

let hoge: () -> Int = {
    return 0
}

let hoge = [0, 1, 2].filter {
    return $0 % 2 == 0
}
after(true)
func hoge() -> Int {
    0
}

let hoge: () -> Int = {
    return 0 // この行で警告
}

let hoge = [0, 1, 2].filter {
    return $0 % 2 == 0 // この行で警告
}

OneCasePerLine

true の場合、Associated Value ありの case、または rawValue を指定してある case は独立させる。

before
enum Type {
    case typeA = "A", typeB = "B", typeC, typeD, typeE
    case typeF(Int), typeG, typeH
}
after(true)
enum Type {)
    case typeA = "A"
    case typeB = "B"
    case typeC, typeD, typeE
    case typeF(Int)
    case typeG, typeH
}

OneVariableDeclarationPerLine

true の場合、一行につき一つの変数を宣言するように変更する。

before
var a = 0, b = 1, (c, d) = (2, "3")

let e, f, g: Int

var h: Int, i: String, j: Float
after(true)
var a = 0
var b = 1
var (c, d) = (2, "3")

let e: Int
let f: Int
let g: Int

var h: Int
var i: String
var j: Float

OnlyOneTrailingClosureArgument

Lint で有効。
true の場合、通常の Closure と Trailing Closure を混ぜて使うと警告が出る。
(警告が出るのは func の引数に複数のクロージャーがある場合。)

func call(successHandler: () -> Void, failureHandler: () -> Void) {}

// これは禁止
call(successHandler: { }) {
    // ...
}

// 以下はOK
call(successHandler: {}, failureHandler: {})
call {
    // ...
} failureHandler: {
    // ...
}

OrderedImports

true の場合、import の順序が整頓される。ただの import だとアルファベット順。@testableimport funcimport enumなどはそれぞれまとめられる。ソースコードの下のほうに import を書いていても、ソースコードの一番上に移動する。コメントが import の直前に書かれていた場合はそれも一緒についてくる。

before
import Foundation
// Starts Imports
import Core


// Comment with new lines
import UIKit

@testable import SwiftFormatRules
import enum Darwin.D.isatty
// Starts Test
@testable import MyModuleUnderTest
// Starts Ind
import func Darwin.C.isatty

let a = 3
import SwiftSyntax
after(true)
// Starts Imports
import Core
import Foundation
import SwiftSyntax
// Comment with new lines
import UIKit

import func Darwin.C.isatty
import enum Darwin.D.isatty

// Starts Test
@testable import MyModuleUnderTest
@testable import SwiftFormatRules

let a = 3

ReplaceForEachWithForLoop

Lint で有効。
true の場合、引数が関数参照でない限り forEachfor-in に置き換えるように警告が出る。

[1, 2, 3, 4].forEach {
    print($0)
}

for i in [1, 2, 3, 4] {
    print(i)

}

のように変えるように提案する。

ReturnVoidInsteadOfEmptyTuple

true の場合、戻り値の型が()になっているところをVoidに統一する。

before
let callback: () -> ()

typealias x = Int -> ()

func y() -> Int -> () { return }

func z(d: Bool -> ()) {}
after(true)
let callback: () -> Void

typealias x = Int -> Void

func y() -> Int -> Void { return }

func z(d: Bool -> Void) {}

TypeNamesShouldBeCapitalized

Lint で有効。
true の場合、struct class enum protocolの名前が大文字から始まらないと警告が出る。

UseEarlyExits

true の場合、可能な限り早期終了を使用するよう修正する。
else 節で return throw break continue が使用されている場合に発動。

before
var value: Int? = 0
if value != 0 {
    print("hello")
} else {
    return
}
after(true)
var value: Int? = 0
guard value != 0 else {
    return
}
print("hello")

UseExplicitNilCheckInConditions

true の場合、オプショナルな値の nil チェックをする際に、値をバインドしてすぐに破棄するのではなく明示的な nil チェックをするように変換する。

before
var value: Int?
if let _ = value {}
after(true)
var value: Int?
if value != nil {}

UseLetInEveryBoundCaseVariable

Lint で有効。
true の場合、case 文においてそれぞれの定数前に let をつける書き方でない場合警告がでる。switch 文だけでなくif caseguard caseなども対象。

enum Label {
    case value(String, Int)
}
switch Label.value("hello", 100) {
case let .value(label, value): break       // ダメな書き方
case .value(let label, let value): break // 良い書き方
}

switch ("hello", 100) {
case let (label, value): break         // ダメな書き方
case (let label, let value): break // 良い書き方
}

UseShorthandTypeNames

true の場合、型指定において省略形式で表記できる箇所を省略形式に書き換える。
細かい挙動については本家のテストコードを見てください。

before
var a: Array<Int>
var b: Dictionary<String, Int>
var c: Optional<String>
var d: Array<[Int]>
var e: Array<Array<Int>>
var f: Optional<Int>?
after(true)
var a: [Int]
var b: [String: Int]
var c: String?
var d: [[Int]]
var e: [[Int]]
var f: Int??

UseSingleLinePropertyGetter

true の場合、Computed Property でかつ get しか記述されていない箇所の get スコープを省略表記に変える。

before
var a: Int {
    get {
        return 1
    }
}
after(true)
var a: Int {
    return 1
}

UseSynthesizedInitializer

Lint で有効。
true の場合、可能な限り Synthesized Initializer を使用するように勧めてくる警告が出る。

public struct Person {
    var name: String
    let phoneNumber: String
    let address: String

    // ↓ Synthesized Initializer があるからこれは不要
    init(name: String, phoneNumber: String, address: String) {
        self.name = name
        self.address = address
        self.phoneNumber = phoneNumber
    }
}

UseTripleSlashForDocumentationComments

true の場合、関数直前に書かれたコメントがドキュメンテーションコメントであれば、///を用いた形式に統一する。

before
/**
 * Returns a docLineComment.
 *
 * - Parameters:
 *   - withOutStar: Indicates if the comment start with a star.
 * - Returns: docLineComment.
 */
func foo(withOutStar: Bool) {}
after(true)
/// Returns a docLineComment.
///
/// - Parameters:
///   - withOutStar: Indicates if the comment start with a star.
/// - Returns: docLineComment.
func foo(withOutStar: Bool) {}

UseWhereClausesInForLoops

true の場合、単一の if 式で構成される for ループでは、代わりに where 句を使用するよう修正する。

before
for i in [0, 1, 2, 3] {
    if i > 30 {
        print(i)
    }
}
after(true)
for i in [0, 1, 2, 3] where i > 30 {
    print(i)
}

ValidateDocumentationComments

Lint で有効。
true の場合、ドキュメンテーションコメントの構文チェックをしてくれる。間違いがあれば警告が出る。

1

Discussion

KyomeKyome

Xcode 16.3のbuilt tool-chainに含まれるswift-formatを使う

$ swift format format --configuration .swift-format -i ファイルパス
$ swift format lint --configuration .swift-format -i ファイルパス
KyomeKyome

Formatに影響があるもの

  • lineLength

  • indentation

  • tabWidth

  • maximumBlankLines

  • spacesBeforeEndOfLineComments

  • respectsExistingLineBreaks

  • lineBreakBeforeControlFlowKeywords

  • lineBreakBeforeEachArgument

  • lineBreakBeforeEachGenericRequirement

  • lineBreakBetweenDeclarationAttributes

  • prioritizeKeepingFunctionOutputTogether

  • indentConditionalCompilationBlocks

  • lineBreakAroundMultilineExpressionChainComponents

  • fileScopedDeclarationPrivacy

  • indentSwitchCaseLabels

  • spacesAroundRangeFormationOperators

  • multiElementCollectionTrailingCommas

  • reflowMultilineStringLiterals

  • rules

    • DoNotUseSemicolons
    • FileScopedDeclarationPrivacy
    • FullyIndirectEnum
    • GroupNumericLiterals
    • NoAccessLevelOnExtensionDeclaration
    • NoCasesWithOnlyFallthrough
    • NoEmptyTrailingClosureParentheses
    • NoLabelsInCasePatterns
    • NoParensAroundConditions
    • NoVoidReturnOnFunctionSignature
    • OneCasePerLine
    • OneVariableDeclarationPerLine
    • OrderedImports
    • ReturnVoidInsteadOfEmptyTuple
    • UseShorthandTypeNames
    • UseSingleLinePropertyGetter
    • UseTripleSlashForDocumentationComments

Lintにのみ影響があるもの

  • noAssignmentInExpressions
  • rules
    • AllPublicDeclarationsHaveDocumentation
    • AlwaysUseLowerCamelCase
    • AmbiguousTrailingClosureOverload
    • BeginDocumentationCommentWithOneLineSummary
    • DontRepeatTypeInStaticProperties
    • IdentifiersMustBeASCII
    • NeverForceUnwrap
    • NeverUseForceTry
    • NeverUseImplicitlyUnwrappedOptionals
    • NoBlockComments
    • NoLeadingUnderscores
    • OnlyOneTrailingClosureArgument
    • UseLetInEveryBoundCaseVariable
    • UseSynthesizedInitializer
    • ValidateDocumentationComments
ログインするとコメントできます