diff --git a/.swiftlint.yml b/.swiftlint.yml index ef8311c1..d9881004 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -11,15 +11,27 @@ excluded: - vendor only_rules: + # Prefer `Array(xs)` over `xs.map { $0 }`. + - array_init + # Colons should be next to the identifier when specifying a type. - colon # There should be no space before and one after any comma. - comma + # Prefer `contains` over `filter(where:).count`. + - contains_over_filter_count + # Prefer `contains` over using `filter(where:).isEmpty`. - contains_over_filter_is_empty + # Prefer `contains` over `first(where:) != nil`. + - contains_over_first_not_nil + + # Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`. + - contains_over_range_nil_comparison + # if,for,while,do statements shouldn't wrap their conditionals in parentheses. - control_statement @@ -39,6 +51,15 @@ only_rules: # Empty strings should be compared to `""` only if `isEmpty` cannot be used. - empty_string + # Prefer `first(where:)` over `filter { }.first`. + - first_where + + # Prefer `flatMap { ... }` over `map { ... }.reduce([], +)`. + - flatmap_over_map_reduce + + # Prefer `last(where:)` over `filter { }.last`. + - last_where + # MARK comment should be in valid format. - mark @@ -50,10 +71,19 @@ only_rules: # over `CGPoint(x: 0, y: 0)`). - prefer_zero_over_explicit_init + # Prefer `reduce(into:_:)` over `reduce(_:_:)` for non-trivial accumulator types. + - reduce_into + + # `nil` coalescing on a non-optional is redundant. + - redundant_nil_coalescing + # Use shorthand syntax for optional binding (`if let foo` instead of # `if let foo = foo`). - shorthand_optional_binding + # Prefer `min(by:)` / `max(by:)` over `sorted { ... }.first` / `.last`. + - sorted_first_last + # Files should have a single trailing newline. - trailing_newline