forked from woocommerce/woocommerce-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.swiftlint.yml
165 lines (119 loc) · 4.65 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Project configuration
included:
- WooCommerce
- Networking
- Storage
- Yosemite
# Rules
whitelist_rules:
# Closing brace with closing parenthesis should not have any whitespaces in
# the middle.
# - closing_brace
# Colons should be next to the identifier when specifying a type.
- colon
# There should be no space before and one after any comma.
- comma
# Repeated `let` statements in conditional binding cascade should be avoided.
# - conditional_binding_cascade
# if,for,while,do statements shouldn't wrap their conditionals in parentheses.
- control_statement
# Create custom rules by providing a regex string. Optionally specify what
# syntax kinds to match against, the severity level, and what message to
# display.
# - custom_rules
# Complexity of function bodies should be limited.
# - cyclomatic_complexity
# Prefer checking `isEmpty` over comparing `count` to zero.
# - empty_count
# Arguments can be omitted when matching enums with associated types if they
# are not used.
- empty_enum_arguments
# Prefer `() -> ` over `Void -> `.
- empty_parameters
# Files should not span too many lines.
# - file_length
# Force casts should be avoided.
# - force_cast
# Force tries should be avoided.
# - force_try
# Force unwrapping should be avoided.
# - force_unwrapping
# Functions bodies should not span too many lines.
# - function_body_length
# Number of function parameters should be low.
# - function_parameter_count
# Files should not contain leading whitespace.
# - leading_whitespace
# Struct extension properties and methods are preferred over legacy functions
# - legacy_cggeometry_functions
# Struct-scoped constants are preferred over legacy global constants.
# - legacy_constant
# Swift constructors are preferred over legacy convenience functions.
# - legacy_constructor
# Lines should not span too many characters.
- line_length
# MARK comment should be in valid format.
- mark
# Public declarations should be documented.
# - missing_docs
# Types should be nested at most 1 level deep, and statements should be nested
# at most 5 levels deep.
# - nesting
# Opening braces should be preceded by a single space and on the same line as
# the declaration.
- opening_brace
# Operators should be surrounded by a single whitespace when defining them.
# - operator_whitespace
# Return arrow and return type should be separated by a single space or on a
# separate line.
# - return_arrow_whitespace
# Else and catch should be on the same line, one space after the previous
# declaration.
# - statement_position
# TODOs and FIXMEs should be avoided.
# - todo
# Limit vertical whitespace to a three empty lines (rule configuration is below)
- vertical_whitespace
# Files should have a single trailing newline.
- trailing_newline
# Lines should not have trailing semicolons.
- trailing_semicolon
# Lines should not have trailing whitespace.
- trailing_whitespace
# Type bodies should not span too many lines.
# - type_body_length
# Type name should only contain alphanumeric characters, start with an
# uppercase character and span between 3 and 40 characters in length.
# - type_name
# Documented declarations should be valid.
# - valid_docs
# Variable names should only contain alphanumeric characters and start with a
# lowercase character or should only contain capital letters. In an exception
# to the above, variable names may start with a capital letter when they are
# declared static and immutable. Variable names should not be too long or too
# short.
# - variable_name
- custom_rules
# Rules configuration
vertical_whitespace:
max_empty_lines: 3
severity: error
line_length: 160
control_statement:
severity: error
custom_rules:
natural_content_alignment:
name: "Natural Content Alignment"
regex: '\.contentHorizontalAlignment(\s*)=(\s*)(\.left|\.right)'
message: "Forcing content alignment left or right can affect the Right-to-Left layout. Use naturalContentHorizontalAlignment instead."
severity: warning
natural_text_alignment:
name: "Natural Text Alignment"
regex: '\.textAlignment(\s*)=(\s*).left'
message: "Forcing text alignment to left can affect the Right-to-Left layout. Consider setting it to `natural`"
severity: warning
inverse_text_alignment:
name: "Inverse Text Alignment"
regex: '\.textAlignment(\s*)=(\s*).right'
message: "When forcing text alignment to the right, be sure to handle the Right-to-Left layout case properly, and then silence this warning with this line `// swiftlint:disable:next inverse_text_alignment`"
severity: warning