|
| 1 | +# SwiftLint configuration for supabase-swift |
| 2 | +# https://github.com/realm/SwiftLint |
| 3 | +# |
| 4 | +# Pinned version: 0.65.0 |
| 5 | +# Install locally: brew install swiftlint |
| 6 | +# CI pins the exact binary via portable_swiftlint.zip from GitHub releases. |
| 7 | +# |
| 8 | +# This project uses Apple's swift-format for formatting/whitespace/layout |
| 9 | +# (run via `make format`). SwiftLint is therefore scoped to code-smell and |
| 10 | +# correctness rules, and all purely stylistic rules that swift-format already |
| 11 | +# governs are disabled to avoid the two tools fighting each other. |
| 12 | +# |
| 13 | +# Run locally with `make lint` (or `make lint-fix` to autocorrect). |
| 14 | + |
| 15 | +included: |
| 16 | + - Sources |
| 17 | + - Tests |
| 18 | + |
| 19 | +excluded: |
| 20 | + - .build |
| 21 | + - Tests/IntegrationTests/supabase |
| 22 | + - "**/__Snapshots__" |
| 23 | + # Legacy code kept for backwards-compatibility; not subject to new lint rules. |
| 24 | + - Sources/Realtime/Deprecated |
| 25 | + |
| 26 | +# ── Rule configuration ──────────────────────────────────────────────────────── |
| 27 | + |
| 28 | +identifier_name: |
| 29 | + # Allow single-character names used for crypto/math fields (n, e, x, y, k) |
| 30 | + # and common loop variables (i, h, l, r). |
| 31 | + min_length: |
| 32 | + warning: 1 |
| 33 | + error: 1 |
| 34 | + max_length: |
| 35 | + warning: 50 |
| 36 | + error: 60 |
| 37 | + # Internal helpers are intentionally underscore-prefixed (_getAccessToken, |
| 38 | + # _remove, _path, _task, _clock, JWKS_TTL, _20240101, etc.). |
| 39 | + validates_start_with_lowercase: false |
| 40 | + allowed_symbols: ["_"] |
| 41 | + excluded: |
| 42 | + - id |
| 43 | + - db |
| 44 | + - to |
| 45 | + - vs |
| 46 | + # Decodable struct properties whose names are dictated by the server response. |
| 47 | + - Key |
| 48 | + - Id |
| 49 | + |
| 50 | +type_name: |
| 51 | + # Private/internal types use leading underscores (_WeakPassword, _Clock…) |
| 52 | + # and some public types exceed 40 chars (AuthMFAGetAuthenticatorAssuranceLevelResponse). |
| 53 | + min_length: 2 |
| 54 | + max_length: |
| 55 | + warning: 50 |
| 56 | + error: 60 |
| 57 | + allowed_symbols: ["_"] |
| 58 | + |
| 59 | +# The project has deliberately large source files and types; raise limits to |
| 60 | +# avoid noise on code that is intentionally structured this way. |
| 61 | +file_length: |
| 62 | + warning: 3400 |
| 63 | + error: 4000 |
| 64 | + |
| 65 | +type_body_length: |
| 66 | + warning: 2800 |
| 67 | + error: 3000 |
| 68 | + |
| 69 | +function_body_length: |
| 70 | + warning: 330 |
| 71 | + error: 400 |
| 72 | + |
| 73 | +cyclomatic_complexity: |
| 74 | + warning: 20 |
| 75 | + error: 30 |
| 76 | + |
| 77 | +function_parameter_count: |
| 78 | + warning: 6 |
| 79 | + error: 10 |
| 80 | + |
| 81 | +# Types nested 2 levels deep appear legitimately in MultipartFormData and tests. |
| 82 | +nesting: |
| 83 | + type_level: |
| 84 | + warning: 2 |
| 85 | + error: 3 |
| 86 | + |
| 87 | +# ── Opt-in rules ────────────────────────────────────────────────────────────── |
| 88 | + |
| 89 | +opt_in_rules: |
| 90 | + - empty_count |
| 91 | + - empty_string |
| 92 | + |
| 93 | +# ── Disabled rules ──────────────────────────────────────────────────────────── |
| 94 | + |
| 95 | +disabled_rules: |
| 96 | + # Owned by swift-format — let it be the single source of truth for layout. |
| 97 | + - trailing_whitespace |
| 98 | + - trailing_comma |
| 99 | + - opening_brace |
| 100 | + - comment_spacing |
| 101 | + - vertical_whitespace |
| 102 | + - trailing_newline |
| 103 | + - closure_parameter_position |
| 104 | + - line_length |
| 105 | + |
| 106 | + # Intentionally used in Sources (StorageApi, RealtimeChannelV2) and heavily |
| 107 | + # in tests. Remove from disabled_rules once the codebase is cleaned up. |
| 108 | + - force_try |
| 109 | + - force_cast |
| 110 | + |
| 111 | + # Pervasive in test helpers for String <-> Data conversions. |
| 112 | + - non_optional_string_data_conversion |
| 113 | + - optional_data_string_conversion |
| 114 | + |
| 115 | + # `let _ = subscription` is an intentional pattern in tests to retain |
| 116 | + # ObservationToken long enough for the callback to fire (see EventEmitter.swift). |
| 117 | + - redundant_discardable_let |
| 118 | + |
| 119 | + # Style preferences that don't affect correctness. |
| 120 | + - multiple_closures_with_trailing_closure |
| 121 | + - for_where |
| 122 | + - implicit_optional_initialization |
| 123 | + # swift-format handles wrapping of very long function names across lines. |
| 124 | + - function_name_whitespace |
0 commit comments