Skip to content
30 changes: 30 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Comment thread
mokagio marked this conversation as resolved.
- 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

Expand All @@ -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

Expand All @@ -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

Expand Down