1# See all available rules: https://realm.github.io/SwiftLint/rule-directory.html 2 3# Don't use `included` parameter even though we'd like to limit which paths should be linted. 4# When it's set, all paths passed as arguments to the command are ignored. 5 6# SwiftLint by default isn't efficient in excluding, `--use-alternative-excluding` flag makes it faster. 7excluded: 8 - .direnv 9 - android 10 - apps 11 - bin 12 - docs 13 - exponent-view-template 14 - fastlane 15 - guides 16 - home 17 - ios/Pods 18 - ios/vendored 19 - ios/versioned 20 - ios/versioned-react-native 21 - node_modules 22 - packages/*/ios/Tests 23 - packages/*/ios/UITests 24 - packages/expo-module-template 25 - packages/expo-module-template-local 26 - packages/expo-dev-menu/ios/OverlayContainer 27 - react-native-lab 28 - scripts 29 - secrets 30 - template-files 31 - tools 32 33# Enable rules that are turned off by default. Run `swiftlint rules` to see what's available to opt-in. 34opt_in_rules: 35 - anyobject_protocol 36 - array_init 37 - closure_body_length 38 - closure_end_indentation 39 - closure_spacing 40 - collection_alignment 41 - comma_inheritance 42 - conditional_returns_on_newline 43 - direct_return 44 - discouraged_object_literal 45 - empty_collection_literal 46 - empty_count 47 - empty_string 48 - enum_case_associated_values_count 49 - fatal_error_message 50 - file_name_no_space 51 - force_unwrapping 52 - identical_operands 53 - implicitly_unwrapped_optional 54 - indentation_width 55 - legacy_objc_type 56 - literal_expression_end_indentation 57 - local_doc_comment 58 - lower_acl_than_parent 59 - multiline_arguments 60 - multiline_function_chains 61 - multiline_literal_brackets 62 - multiline_parameters 63 - multiline_parameters_brackets 64 - no_grouping_extension 65 - number_separator 66 - operator_usage_whitespace 67 - overridden_super_call 68 - prefer_zero_over_explicit_init 69 - prohibited_super_call 70 - redundant_nil_coalescing 71 - static_operator 72 - superfluous_else 73 - unavailable_function 74 - unneeded_parentheses_in_closure_argument 75 - unowned_variable_capture 76 - unused_capture_list 77 - vertical_parameter_alignment_on_call 78 - vertical_whitespace_closing_braces 79 - vertical_whitespace_opening_braces 80 - yoda_condition 81 82# Disable some rules that are turned on by default. 83disabled_rules: 84 - reduce_boolean 85 - todo 86 - weak_delegate 87 88# Rules run by `swiftlint analyze`. 89analyzer_rules: 90 - capture_variable 91 - unused_declaration 92 - unused_import 93 94# Prefer using AnyObject over class for class-only protocols. 95anyobject_protocol: warning 96 97# Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array. 98array_init: warning 99 100# Non-constant variables should not be listed in a closure’s capture list 101# to avoid confusion about closures capturing variables at creation time. 102capture_variable: warning 103 104# Closure bodies should not span too many lines. 105closure_body_length: 106 warning: 30 107 error: 50 108 109# Closure end should have the same indentation as the line that started it. 110closure_end_indentation: warning 111 112# Closure expressions should have a single space inside each brace. 113closure_spacing: warning 114 115# All elements in a collection literal should be vertically aligned. 116collection_alignment: 117 severity: warning 118 align_colons: false 119 120# Use commas to separate types in inheritance lists. 121comma_inheritance: warning 122 123# if, for, guard, switch, while, and catch statements shouldn’t unnecessarily wrap their conditionals or arguments in parentheses. 124control_statement: warning 125 126# Limits the complexity of function bodies. 127cyclomatic_complexity: 128 warning: 12 129 error: 20 130 ignores_case_statements: true 131 132# Directly return the expression instead of assigning it to a variable first. 133direct_return: warning 134 135# Prefer initializers over object literals. 136discouraged_object_literal: 137 severity: error 138 image_literal: true 139 color_literal: true 140 141# Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal. 142empty_collection_literal: warning 143 144# Prefer checking `isEmpty` over comparing count to zero. 145empty_count: 146 severity: warning 147 only_after_dot: true 148 149# When using trailing closures, empty parentheses should be avoided after the method call. 150empty_parentheses_with_trailing_closure: warning 151 152# Prefer checking `isEmpty` over comparing string to an empty string literal. 153empty_string: warning 154 155# Number of associated values in an enum case should be low. 156enum_case_associated_values_count: 157 warning: 5 158 error: 6 159 160# A `fatalError` call should have a message. 161fatal_error_message: error 162 163# Files should not span too many lines. 164file_length: 165 warning: 850 166 error: 900 167 ignore_comment_only_lines: true 168 169# File name should not contain any whitespace. 170file_name_no_space: 171 severity: error 172 173# Force casts should be avoided. 174force_cast: error 175 176# Force tries should be avoided. 177force_try: error 178 179# Force unwrapping should be avoided. 180force_unwrapping: error 181 182# Functions bodies should not span too many lines. 183function_body_length: 184 warning: 250 185 error: 300 186 187# Comparing two identical operands is likely a mistake. 188identical_operands: error 189 190# Identifier names should only contain alphanumeric characters and start with a lowercase character or should only 191# contain capital letters. In an exception to the above, variable names may start with a capital letter when they are 192# declared static and immutable. Variable names should not be too long or too short. 193identifier_name: 194 min_length: 1 195 max_length: 196 warning: 35 197 error: 50 198 validates_start_with_lowercase: warning 199 # Ignore Sweet API components as they intentionally start with the uppercase letter. 200 allowed_symbols: 201 [ 202 '_', 203 'AsyncFunction', 204 'Class', 205 'Constants', 206 'Constructor', 207 'Events', 208 'Function', 209 'Name', 210 'OnAppBecomesActive', 211 'OnAppContextDestroys', 212 'OnAppEntersBackground', 213 'OnAppEntersForeground', 214 'OnCreate', 215 'OnDestroy', 216 'OnStartObserving', 217 'OnStopObserving', 218 'Prop', 219 'Property', 220 'View', 221 'ViewManager', 222 ] 223 224# Implicitly unwrapped optionals should be avoided when possible. 225implicitly_unwrapped_optional: 226 severity: error 227 228# Indent code using either one tab or the configured amount of spaces, 229# unindent to match previous indentations. Don’t indent the first line. 230indentation_width: 231 severity: warning 232 indentation_width: 2 233 include_comments: false 234 include_compiler_directives: false 235 include_multiline_strings: true 236 237# Tuples shouldn’t have too many members. Create a custom type instead. 238large_tuple: 239 warning: 10 240 error: 10 241 242# Files should not contain leading whitespace. 243leading_whitespace: warning 244 245# Struct-scoped constants are preferred over legacy global constants. 246legacy_constant: warning 247 248# Swift constructors are preferred over legacy convenience functions. 249legacy_constructor: warning 250 251# Prefer Swift value types to bridged Objective-C reference types. 252legacy_objc_type: warning 253 254# Lines should not span too many characters. 255line_length: 256 warning: 160 257 error: 200 258 ignores_urls: true 259 ignores_function_declarations: false 260 ignores_comments: false 261 ignores_interpolated_strings: true 262 263# Array and dictionary literal end should have the same indentation as the line that started it. 264literal_expression_end_indentation: warning 265 266# Doc comments shouldn’t be used in local scopes. Use regular comments. 267local_doc_comment: warning 268 269# Ensure declarations have a lower access control level than their enclosing parent. 270lower_acl_than_parent: warning 271 272# MARK comment should be in valid format. e.g. `// MARK: ...` or `// MARK: - ...` 273mark: warning 274 275# Arguments should be either on the same line, or one per line. 276multiline_arguments: 277 severity: warning 278 279# Chained function calls should be either on the same line, or one per line. 280multiline_function_chains: warning 281 282# Multiline literals should have their surrounding brackets in a new line. 283multiline_literal_brackets: warning 284 285# Functions and methods parameters should be either on the same line, or one per line. 286multiline_parameters: 287 severity: warning 288 289# Types should be nested at most 1 level deep, and functions should be nested at most 2 levels deep. 290nesting: 291 type_level: 1 292 function_level: 2 293 294# Multiline parameters should have their surrounding brackets in a new line. 295multiline_parameters_brackets: warning 296 297# Extensions shouldn’t be used to group code within the same source file. 298no_grouping_extension: warning 299 300# Underscores should be used as thousand separator in large decimal numbers. 301number_separator: 302 severity: warning 303 minimum_length: 5 304 305# Operators should be surrounded by a single whitespace when they are being used. 306operator_usage_whitespace: 307 severity: warning 308 309# A doc comment should be attached to a declaration. 310orphaned_doc_comment: warning 311 312# Some overridden methods should always call super. 313overridden_super_call: 314 severity: warning 315 316# Prefer `.zero` over explicit init with zero parameters (e.g. `CGPoint(x: 0, y: 0)`). 317prefer_zero_over_explicit_init: warning 318 319# Some methods should not call super. 320prohibited_super_call: 321 severity: warning 322 323# When declaring properties in protocols, the order of accessors should be `get set`. 324protocol_property_accessors_order: warning 325 326# nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant. 327redundant_nil_coalescing: warning 328 329# Initializing an optional variable with nil is redundant. 330redundant_optional_initialization: warning 331 332# Operators should be declared as static functions, not free functions. 333static_operator: warning 334 335# Else branches should be avoided when the previous if-block exits the current scope. 336superfluous_else: warning 337 338# Files should have a single trailing newline. 339trailing_newline: warning 340 341# Lines should not have trailing semicolons. 342trailing_semicolon: warning 343 344# Lines should not have trailing whitespace. 345trailing_whitespace: 346 severity: warning 347 ignores_empty_lines: false 348 ignores_comments: false 349 350# Type bodies should not span too many lines. 351type_body_length: 352 warning: 750 353 error: 800 354 355# Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 35 characters in length. 356type_name: 357 min_length: 3 358 max_length: 359 warning: 40 360 error: 50 361 362# Unimplemented functions should be marked as unavailable. 363unavailable_function: warning 364 365# Parentheses are not needed when declaring closure arguments. 366unneeded_parentheses_in_closure_argument: warning 367 368# Prefer capturing references as weak to avoid potential crashes. 369unowned_variable_capture: warning 370 371# Unused reference in a capture list should be removed. 372unused_capture_list: warning 373 374# Unused parameter in a closure should be replaced with `_`. 375unused_closure_parameter: warning 376 377# Declarations should be referenced at least once within all files linted. 378unused_declaration: 379 severity: warning 380 include_public_and_open: false 381 382# When the index or the item is not used, `.enumerated()` can be removed. 383unused_enumerated: warning 384 385# All imported modules should be required to make the file compile. 386unused_import: 387 severity: warning 388 389# Prefer `!= nil` over `let _ =` 390unused_optional_binding: 391 severity: warning 392 ignore_optional_try: false 393 394# Setter value is not used. 395unused_setter_value: warning 396 397# Function parameters should be aligned vertically if they’re in multiple lines in a method call. 398vertical_parameter_alignment_on_call: warning 399 400# Limit vertical whitespace to a single empty line. 401vertical_whitespace: 402 severity: warning 403 max_empty_lines: 1 404 405# Don’t include vertical whitespace (empty line) before closing braces. 406vertical_whitespace_closing_braces: 407 severity: warning 408 only_enforce_before_trivial_lines: false 409 410# Don’t include vertical whitespace (empty line) after opening braces. 411vertical_whitespace_opening_braces: warning 412 413# Prefer `-> Void` over `-> ()`. 414void_return: warning 415 416# The variable should be placed on the left, the constant on the right of a comparison operator. 417yoda_condition: warning 418