|
| 1 | +# You can find the documentation here : |
| 2 | +# https://realm.github.io/SwiftLint/rule-directory.html |
| 3 | + |
| 4 | +############## |
| 5 | +#Disabled rules# |
| 6 | +############## |
| 7 | + |
| 8 | +disabled_rules: |
| 9 | + - nesting |
| 10 | + |
| 11 | +############## |
| 12 | +#Opted in rules# |
| 13 | +############## |
| 14 | + |
| 15 | +opt_in_rules: |
| 16 | + - array_init |
| 17 | + - closure_spacing |
| 18 | + - collection_alignment |
| 19 | + - contains_over_filter_count |
| 20 | + - contains_over_filter_is_empty |
| 21 | + - contains_over_first_not_nil |
| 22 | + - contains_over_range_nil_comparison |
| 23 | + - convenience_type |
| 24 | + - discouraged_object_literal |
| 25 | + - discouraged_optional_boolean |
| 26 | + - empty_collection_literal |
| 27 | + - empty_count |
| 28 | + - empty_xctest_method |
| 29 | + - enum_case_associated_values_count |
| 30 | + - expiring_todo |
| 31 | + - explicit_init |
| 32 | + - extension_access_modifier |
| 33 | + - fallthrough |
| 34 | + - fatal_error_message |
| 35 | + - file_name_no_space |
| 36 | + - first_where |
| 37 | + - flatmap_over_map_reduce |
| 38 | + - force_unwrapping |
| 39 | + - ibinspectable_in_extension |
| 40 | + - identical_operands |
| 41 | + - implicit_return |
| 42 | + - joined_default_parameter |
| 43 | + - last_where |
| 44 | + - legacy_multiple |
| 45 | + - legacy_random |
| 46 | + - let_var_whitespace |
| 47 | + - literal_expression_end_indentation |
| 48 | + - multiline_arguments |
| 49 | + - multiline_parameters |
| 50 | + - nimble_operator |
| 51 | + - nslocalizedstring_key |
| 52 | + - nslocalizedstring_require_bundle |
| 53 | + - number_separator |
| 54 | + - operator_usage_whitespace |
| 55 | + - optional_enum_case_matching |
| 56 | + - overridden_super_call |
| 57 | + - override_in_extension |
| 58 | + - pattern_matching_keywords |
| 59 | + - prefer_self_type_over_type_of_self |
| 60 | + - prefer_zero_over_explicit_init |
| 61 | + - prefixed_toplevel_constant |
| 62 | + - private_action |
| 63 | + - private_outlet |
| 64 | + - prohibited_super_call |
| 65 | + - quick_discouraged_call |
| 66 | + - quick_discouraged_focused_test |
| 67 | + - quick_discouraged_pending_test |
| 68 | + - raw_value_for_camel_cased_codable_enum |
| 69 | + - reduce_into |
| 70 | + - redundant_nil_coalescing |
| 71 | + - redundant_type_annotation |
| 72 | + - required_enum_case |
| 73 | + - single_test_class |
| 74 | + - sorted_first_last |
| 75 | + - sorted_imports |
| 76 | + - static_operator |
| 77 | + - toggle_bool |
| 78 | + - trailing_closure |
| 79 | + - unavailable_function |
| 80 | + - unneeded_parentheses_in_closure_argument |
| 81 | + - untyped_error_in_catch |
| 82 | + - vertical_parameter_alignment_on_call |
| 83 | + - vertical_whitespace_closing_braces |
| 84 | + - vertical_whitespace_opening_braces |
| 85 | + - xct_specific_matcher |
| 86 | + - yoda_condition |
| 87 | + - unhandled_throwing_task |
| 88 | + |
| 89 | +############## |
| 90 | +#Specific analyzer rules# |
| 91 | +############## |
| 92 | + |
| 93 | +analyzer_rules: # Rules run by `swiftlint analyze` |
| 94 | + - explicit_self |
| 95 | + - unused_declaration |
| 96 | + - unused_import |
| 97 | + |
| 98 | +################ |
| 99 | +#Customed rules# |
| 100 | +################ |
| 101 | + |
| 102 | +# configurable rules can be customized from this configuration file |
| 103 | +# binary rules can set their severity level |
| 104 | +#force_cast: warning # implicitly |
| 105 | + |
| 106 | +#force_try: |
| 107 | +# severity: warning # explicitly |
| 108 | +# |
| 109 | +# rules that have both warning and error levels, can set just the warning level |
| 110 | +# implicitly |
| 111 | +line_length: |
| 112 | + warning: 120 |
| 113 | + error: 200 |
| 114 | + ignores_urls: true |
| 115 | + ignores_comments: true |
| 116 | + |
| 117 | +# they can set both implicitly with an array |
| 118 | +type_body_length: |
| 119 | + warning: 300 |
| 120 | + error: 400 |
| 121 | + |
| 122 | +trailing_closure: |
| 123 | + only_single_muted_parameter: true |
| 124 | + |
| 125 | +trailing_whitespace: |
| 126 | + ignores_empty_lines: true |
| 127 | + |
| 128 | +# or they can set both explicitly |
| 129 | +file_length: |
| 130 | + warning: 700 |
| 131 | + error: 1200 |
| 132 | + |
| 133 | +function_body_length: # Functions bodies should not span too many lines. |
| 134 | + warning: 100 |
| 135 | + error: 200 |
| 136 | + |
| 137 | +# naming rules can set warnings/errors for min_length and max_length |
| 138 | +# additionally they can set excluded names |
| 139 | +type_name: |
| 140 | + min_length: 3 # only warning |
| 141 | + max_length: # warning and error |
| 142 | + warning: 45 |
| 143 | + error: 50 |
| 144 | + excluded: iPhone # excluded via string |
| 145 | + allowed_symbols: ["_"] # these are allowed in type names |
| 146 | + |
| 147 | +identifier_name: |
| 148 | + min_length: # only min_length |
| 149 | + warning: 2 |
| 150 | + excluded: # excluded via string array |
| 151 | +reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown) |
| 152 | + |
| 153 | +custom_rules: |
| 154 | + drop_first_one: |
| 155 | + name: "Drop first one" |
| 156 | + message: "Implicitly drop first one element" |
| 157 | + regex: "(\\.dropFirst\\(1\\))" |
| 158 | + |
| 159 | + discouraged_optional_self: |
| 160 | + name: "Discouraged optional self" |
| 161 | + message: "Unwrap self via guard let and use implicit self instead of optional self" |
| 162 | + regex: "(self\\?\\.)" |
| 163 | + |
| 164 | + discouraged_previewprovider: |
| 165 | + name: "Discouraged PreviewProvider" |
| 166 | + message: "Use #Preview macro insteaf of PreviewProvider" |
| 167 | + regex: "(PreviewProvider)" |
| 168 | + |
| 169 | + discouraged_anyview: |
| 170 | + name: "Discouraged AnyView" |
| 171 | + message: "Avoid using AnyView for better performance" |
| 172 | + regex: "(AnyView)" |
| 173 | + |
| 174 | + discouraged_body_font: |
| 175 | + name: "Discouraged body font" |
| 176 | + message: "Prefer implicit body font" |
| 177 | + regex: "(\\.font\\(\\.body\\))" |
| 178 | + |
| 179 | + discouraged_regular_font_weight: |
| 180 | + name: "Discouraged regular font weight" |
| 181 | + message: "Prefer implicit regular font weight" |
| 182 | + regex: "(\\.fontWeight\\(\\.regular\\))" |
| 183 | + |
| 184 | + discouraged_verbose_contentshape_rectangle: |
| 185 | + name: "Discouraged verbose .contentShape(Rectangle())" |
| 186 | + message: "Prefer static member lookup version .contentShape(.rectangle)" |
| 187 | + regex: "(\\.contentShape\\(Rectangle\\(\\))" |
| 188 | + |
| 189 | + deprecated_foregroundcolor_modifier: |
| 190 | + name: "Deprecated foregroundColor modifier" |
| 191 | + message: "Prefer foregroundStyle over deprecated foregroundColor" |
| 192 | + regex: "(foregroundColor\\()" |
| 193 | + |
| 194 | + deprecated_navigationbarleading: |
| 195 | + name: "Deprecated navigationBarLeading" |
| 196 | + message: "Prefer topBarLeading over deprecated navigationBarLeading" |
| 197 | + regex: "\\.navigationBarLeading" |
| 198 | + |
| 199 | + deprecated_navigationbartrailing: |
| 200 | + name: "Deprecated navigationBarTrailing" |
| 201 | + message: "Prefer topBarTrailing over deprecated navigationBarTrailing" |
| 202 | + regex: "\\.navigationBarTrailing" |
| 203 | + |
| 204 | + nil_if_empty: |
| 205 | + name: "Nil if empty" |
| 206 | + message: "Use Collection's computed property nilIfEmpty" |
| 207 | + regex: "\\.isEmpty \\? nil" |
0 commit comments