|
| 1 | +# SwiftLint Configuration for swift-standards |
| 2 | +# Shared across all packages in the workspace |
| 3 | +# Optimized for library/framework development with Swift Testing |
| 4 | + |
| 5 | +# Disabled rules |
1 | 6 | disabled_rules: |
2 | | - - line_length |
3 | | - - identifier_name |
4 | | - - nesting |
5 | | - - type_name |
6 | | - - explicit_enum_raw_value |
7 | | - - file_length |
8 | | - - function_body_length |
9 | | - - redundant_discardable_let # Preserve 'let _ =' in result builder contexts (required for Swift 6.0+) |
| 7 | + # Type inference & Swift idioms |
| 8 | + - explicit_type_interface # Type inference is idiomatic Swift |
| 9 | + - explicit_init # Prefer MyType() over MyType.init() |
| 10 | + - extension_access_modifier # Prefer access on members, not extensions |
| 11 | + - explicit_acl # Don't require `internal` everywhere |
| 12 | + |
| 13 | + # Development flexibility |
| 14 | + - todo # TODOs are fine in development |
| 15 | + - force_cast # Sometimes needed in tests |
| 16 | + - force_try # Sometimes needed in tests |
| 17 | + |
| 18 | + # Length restrictions (swift-format handles line length) |
| 19 | + - line_length # HTML attributes can be 300+ chars; swift-format handles this |
| 20 | + - file_length # Comprehensive test files are long |
| 21 | + |
| 22 | + # Domain complexity |
| 23 | + - cyclomatic_complexity # Lookup tables and parsing logic have inherent complexity |
| 24 | + - function_parameter_count # Time/Date/RFC initializers legitimately need many parameters |
| 25 | + - large_tuple # Component tuples are acceptable for internal use |
10 | 26 |
|
| 27 | + # Documentation patterns |
| 28 | + - file_header # No consistent pattern across packages |
| 29 | + - missing_docs # Documentation via code comments, not strictly required |
| 30 | + |
| 31 | + # Swift Testing compatibility |
| 32 | + - identifier_name # Swift Testing uses backtick names with spaces |
| 33 | + - type_name # @Suite uses descriptive names with spaces |
| 34 | + |
| 35 | + # False positives for our patterns |
| 36 | + - optional_data_string_conversion # False positive on [UInt8] -> String conversion |
| 37 | + - for_where # Not always clearer than for+if |
| 38 | + - contains_over_first_not_nil # False positives on custom firstIndex implementations |
| 39 | + - sorted_imports # Handled by swift-format's OrderedImports rule |
| 40 | + - trailing_comma # Handled by swift-format (adds trailing commas for better diffs) |
| 41 | + |
| 42 | +# Opt-in rules for code quality |
11 | 43 | opt_in_rules: |
12 | | - - empty_count |
13 | | - - explicit_init |
14 | | - - sorted_imports |
15 | | - - force_cast |
16 | | - - force_try |
17 | | - - closure_spacing |
18 | | - - operator_usage_whitespace |
19 | | - - private_outlet |
20 | | - - redundant_nil_coalescing |
21 | | - - empty_string |
22 | | - - literal_expression_end_indentation |
23 | | - - single_test_class |
24 | | - - sorted_first_last |
25 | | - - vertical_whitespace |
26 | | - - strict_fileprivate |
27 | | - - legacy_random |
28 | | - - no_extension_access_modifier |
29 | | - - colon |
30 | | - - trailing_comma |
31 | | - |
| 44 | + # Bug prevention |
| 45 | + - unused_optional_binding # Catch unused let bindings |
| 46 | + |
| 47 | + # Code quality & cleanliness |
| 48 | + - implicit_optional_initialization # Don't initialize optionals to nil (formerly redundant_optional_initialization) |
| 49 | + - redundant_void_return # Don't write -> Void |
| 50 | + - empty_string # Use .isEmpty not == "" |
| 51 | + - vertical_whitespace # Consistent spacing |
| 52 | + |
| 53 | +# Analyzer rules (require --analyze flag) |
| 54 | +analyzer_rules: |
| 55 | + - unused_import # Remove unnecessary imports |
| 56 | + |
| 57 | + # Performance optimizations |
| 58 | + - empty_count # Use .isEmpty instead of .count == 0 |
| 59 | + - first_where # Prefer first(where:) over filter().first |
| 60 | + - last_where # Prefer last(where:) over filter().last |
| 61 | + - contains_over_range_nil_comparison # Better performance |
| 62 | + - sorted_first_last # Prefer sorted().first/last |
| 63 | + |
| 64 | + # Style consistency |
| 65 | + - closure_spacing # Consistent closure formatting |
| 66 | + - operator_usage_whitespace # Consistent operator spacing |
| 67 | + |
| 68 | + # Safety |
| 69 | + - array_init # Safer array initialization |
| 70 | + - fatal_error_message # Require messages in fatalError |
| 71 | + - legacy_random # Use modern random APIs |
| 72 | + - overridden_super_call # Ensure super is called when needed |
| 73 | + |
| 74 | +# Paths |
32 | 75 | included: |
33 | | - - Package.swift |
34 | 76 | - Sources |
35 | 77 | - Tests |
36 | 78 |
|
37 | 79 | excluded: |
38 | | - - Carthage |
39 | | - - Pods |
40 | | - - fastlane |
41 | | - - build |
| 80 | + - .build |
| 81 | + - .swiftpm |
42 | 82 |
|
43 | | -analyzer_rules: |
44 | | - - unused_import |
| 83 | +# Rule configurations |
| 84 | + |
| 85 | +# Allow longer functions for complex performance logic |
| 86 | +function_body_length: |
| 87 | + warning: 60 |
| 88 | + error: 100 |
45 | 89 |
|
46 | | -colon: |
47 | | - apply_to_dictionaries: true |
| 90 | +# Allow larger types for comprehensive test suites |
| 91 | +type_body_length: |
| 92 | + warning: 400 |
| 93 | + error: 600 |
48 | 94 |
|
49 | | -vertical_whitespace: |
50 | | - max_empty_lines: 1 |
| 95 | +# Nesting depth |
| 96 | +nesting: |
| 97 | + type_level: 2 |
0 commit comments