-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.swiftlint.yml
104 lines (90 loc) · 2.66 KB
/
.swiftlint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# paths to ignore during linting. Takes precedence over `included`.
excluded:
- Carthage/
# Rules
opt_in_rules:
- conditional_returns_on_newline
- fatal_error_message
- overridden_super_call
- closure_end_indentation
- closure_spacing
- trailing_closure
- empty_string
- explicit_init
- first_where
- joined_default_parameter
- multiline_parameters
- prohibited_super_call
- sorted_first_last
- untyped_error_in_catch
force_cast: error
force_try: error
colon:
apply_to_dictionaries: false
identifier_name:
excluded:
- id
- URL
# Constants
file_length:
warning: 1000
error: 1500
type_body_length:
warning: 800
error: 1000
line_length: 150
function_parameter_count: 4
type_name:
min_length: 2 # only warning
# Custom rules
custom_rules:
enum_cases_on_newline:
name: "Enum cases on newline"
regex: "^\\s*case[\\h\\S]*,(?![^(]*\\))[^:|,]+$"
message: "Enum cases should always start with a newline."
accessors_and_observers_on_newline:
name: "Property accessors and observers on newline"
regex: "^\\s*(get|set|didSet|willSet)[\\h\\S]\\{[\\h\\S]+$"
message: "Property accessors and observers should always start with a newline."
equals_to_self:
name: "Equals to itself"
regex: "(^|[\\h])([$.\\w]+)([\\h]*[=]{2,}[\\h]*)\\2([\\s]+)"
message: "Expression always returns true, please fix typo"
match_kinds:
- argument
- identifier
- keyword
- number
- objectliteral
- parameter
- placeholder
- typeidentifier
extension_mark:
name: "Extension mark"
regex: "^([\\h]*[\\/]{2}[\\h]*MARK[:\\h-]+)([\\w]+)[\\s]+(extension[\\h]+[\\w]+[\\h]*:[\\h]*)(?!\\2[\\h]*[\\{])([\\w]+[\\s]*[\\{])"
message: "Extension mark should contain same name of protocol below"
double_whitespace:
name: "Double whitespace"
regex: "(?<!^)(\\b[\\h]{2,})"
message: "Expression contains double whitespace, please fix typo"
match_kinds:
- argument
- identifier
- keyword
- number
- objectliteral
- parameter
- placeholder
- typeidentifier
c_style_comment:
name: "C-style comment"
regex: '\/\*([^"*]+)\*\/'
message: "Please avoid C-style comments, use `//` comments instead"
unwrapping_self:
name: "Unwrapping self"
regex: "\\b(var|let)([\\h]+)(`self`|weakSelf)([\\h]*=[\\h]*)(self)"
message: "Please unwrap self as self = self"
omitted_parameter_name_in_init:
name: "Omitted parameter name in init"
regex: "^\\s*(convenience|required)?[\\h]*(init)[(]([\\h]*[^_{(}]+)?(_[\\h]+\\w+:[\\h]*[\\w<>?!]+)"
message: "Please remove `_` from parameter in initializer, like `init(parameter: P)`"