Skip to content

Instantly share code, notes, and snippets.

@andr3a88
Last active March 9, 2020 10:41
Show Gist options
  • Save andr3a88/7a030c346845c5ce4238ab6d29e15d1b to your computer and use it in GitHub Desktop.
Save andr3a88/7a030c346845c5ce4238ab6d29e15d1b to your computer and use it in GitHub Desktop.
SwiftLint file
disabled_rules: # rule identifiers to exclude from running
- force_cast
- legacy_constant
- legacy_constructor
- nesting
- trailing_whitespace
- type_name
- identifier_name
- cyclomatic_complexity
- explicit_self
- private_over_fileprivate
opt_in_rules:
- array_init
- closure_spacing
- contains_over_first_not_nil
- explicit_init
- extension_access_modifier
- fatal_error_message
- first_where
- implicit_return
- joined_default_parameter
- let_var_whitespace
- literal_expression_end_indentation
- operator_usage_whitespace
- overridden_super_call
- prohibited_super_call
- quick_discouraged_call
- sorted_imports
- vertical_parameter_alignment_on_call
- todo
- unowned_variable_capture
- duplicate_enum_cases
- unused_capture_list
- toggle_bool
- vertical_whitespace_closing_braces
- required_enum_case
- switch_case_on_newline
- empty_xctest_method
- no_grouping_extension
- empty_count
- empty_string
- modifier_order
- private_action # Keeps your UI code closed within the implementation class and it avoids leaking UIKit to higher layers.
- private_outlet # Keeps your UI code closed within the implementation class and it avoids leaking UIKit to higher layers.
- unused_private_declaration
included: # paths to include during linting. `--path` is ignored if present.
- ./MyProject
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
# These properties are marked as error by default.
force_try: warning
shorthand_operator: warning
file_length:
warning: 700
error: 900
function_body_length:
warning: 50
error: 100
type_body_length:
warning: 600
error: 700
function_parameter_count:
warning: 10
error: 15
line_length:
warning: 100
error: 120
large_tuple:
warning: 4
error: 5
type_name:
min_length: 3 # only warning
max_length: # warning and error
warning: 45
error: 50
excluded:
- R
- D
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube)
custom_rules:
comments_space: # From https://github.com/brandenr/swiftlintconfig
name: "Space After Comment"
regex: "(^ *//\\w+)"
message: "There should be a space after //"
severity: warning
double_space: # From https://github.com/IBM-Swift/Package-Builder
include: "*.swift"
name: "Double space"
regex: "([a-z,A-Z] \\s+)"
message: "Double space between keywords"
match_kinds: keyword
severity: warning
mark_newline:
include: "*.swift"
name: "MARK new line"
regex: "(^ *\\/\\/ MARK:\ [ a-zA-Z0-9=?.\\(\\)\\{\\}:,><!-]*\n *(?!(?:\\}|return))\\S+)"
message: "// MARK: should have new line after"
severity: warning
empty_line_after_super:
name: "Empty Line After Super"
regex: "(^ *super\\.[ a-zA-Z0-9=?.\\(\\)\\{\\}:,><!]*\n *(?!(?:\\}|return))\\S+)"
message: "There should be an empty line after super"
severity: warning
new_line_between_import:
name: "New line between import"
regex: "import(.*?)\n\n+import"
message: "No new line between import"
severity: warning
print:
name: "Debug print"
message: "Remove print output."
severity: warning
regex: "\\sprint[ ]?\\((.*\\))" # Detect this string print("
@andr3a88
Copy link
Author

andr3a88 commented Nov 8, 2019

Add some rules:

    - todo
    - unowned_variable_capture
    - duplicate_enum_cases
    - unused_capture_list
    - toggle_bool
    - vertical_whitespace_closing_braces
    - required_enum_case
    - private_outlet
    - switch_case_on_newline
    - empty_xctest_method
    - no_grouping_extension

@andr3a88
Copy link
Author

andr3a88 commented Mar 9, 2020

    - empty_count
    - empty_string
    - modifier_order
    - private_action # Keeps your UI code closed within the implementation class and it avoids leaking UIKit to higher layers.
    - private_outlet # Keeps your UI code closed within the implementation class and it avoids leaking UIKit to higher layers.
    - unused_private_declaration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment