Skip to content

Commit 42c1234

Browse files
committed
add new Swiftlint Rules
1 parent 6c9bb14 commit 42c1234

1 file changed

Lines changed: 40 additions & 41 deletions

File tree

SwiftLint/swiftlint.yml

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ disabled_rules:
1515
- switch_case_alignment
1616
- empty_enum_arguments # case .unexpectedSituation(_): ... is not allowed
1717
- duplicate_enum_cases
18+
- identifier_name
1819

1920
# paths to ignore during linting. overridden by `included`.
2021
excluded:
@@ -54,6 +55,39 @@ opt_in_rules:
5455
- identical_operands
5556
- collection_alignment
5657
- empty_xctest_method
58+
- array_init
59+
- contains_over_filter_count
60+
- contains_over_filter_is_empty
61+
- contains_over_first_not_nil
62+
- empty_collection_literal
63+
- empty_string
64+
- explicit_self
65+
- file_name
66+
- for_where
67+
- joined_default_parameter
68+
- last_where
69+
- legacy_multiple
70+
- literal_expression_end_indentation
71+
- lower_acl_than_parent
72+
- modifier_order
73+
- multiline_arguments
74+
- multiline_function_chains
75+
- multiline_literal_brackets
76+
- multiline_parameters_brackets
77+
- object_literal
78+
- overridden_super_call
79+
- redundant_type_annotation
80+
- sorted_first_last
81+
- static_operator
82+
- toggle_bool
83+
- unowned_variable_capture
84+
- unused_import
85+
- vertical_parameter_alignment_on_call
86+
- vertical_whitespace_closing_braces
87+
- convenience_type
88+
- number_separator
89+
- single_test_class
90+
- strong_iboutlet
5791

5892
# rule parameters
5993
file_length:
@@ -86,23 +120,6 @@ large_tuple:
86120
warning: 4
87121
error: 6
88122

89-
identifier_name:
90-
excluded:
91-
- to
92-
- id
93-
- by
94-
- of
95-
- at
96-
- in
97-
- !str on
98-
- x
99-
- y
100-
- L
101-
# Allow the usage of underscores at the start of variables or constants. The lowercase check has currently to be disabled as "_" isn't considered as lowercase character
102-
validates_start_lowercase: false
103-
allowed_symbols:
104-
- _
105-
106123
type_name:
107124
min_length: 3
108125
max_length: 60
@@ -129,11 +146,6 @@ custom_rules:
129146
- typeidentifier
130147
- number
131148
- identifier
132-
unnecessary_datatype:
133-
name: "Unnecessary Datatype"
134-
regex: '(?m-s)(let|var).*(:\s\[+(\w|:| |\t)+\]+\s*=\s*\[:*\])'
135-
message: "Unnecessary datatype. Use '= [DataType]()' instead of ': [DataType] = []'"
136-
severity: warning
137149
missing_closure_name:
138150
name: "Missing closure name"
139151
regex: '^\s*\}\) \{.*'
@@ -155,7 +167,7 @@ custom_rules:
155167
- doccomment.field
156168
empty_first_line:
157169
name: "Empty First Line"
158-
regex: '(extension|class|struct) (?!(?:func|let|var))[^\{]*\{[^\n]*\n[\t ]*\w+'
170+
regex: '(extension|class|struct|protocol) (?!(?:func|let|var))[^\{]*\{[^\n]*\n[\t ]*\w+'
159171
message: "There should be an empty line after a class or extension declaration."
160172
severity: warning
161173
match_kinds:
@@ -169,6 +181,11 @@ custom_rules:
169181
- placeholder
170182
- parameter
171183
- attribute.builtin
184+
single_line_body:
185+
name: "Single Line Body"
186+
regex: '(?i-sm)((if|while|do|for).? \{(?!\n|.?(s|g)et).+?\}\n)'
187+
message: "Single line bodies are not allowed"
188+
severity: warning
172189
empty_line_after_guard:
173190
name: "Empty Line After Guard"
174191
regex: '(^ *guard[ a-zA-Z0-9=?.\(\),><!]*\{[ a-zA-Z0-9=?.\(\),><!]*\}\n *(?!(?:return|guard))\S+)'
@@ -239,24 +256,6 @@ custom_rules:
239256
regex: '(\[[a-zA-Z0-9]+?:[a-zA-Z0-9]+?\])'
240257
message: "Missing space. use [DataType: DataType]."
241258
severity: warning
242-
missing_space_around_operator:
243-
name: "Missing Space Around Operator"
244-
regex: '[\w)]+(\+|-|\*|/)[\w(]+'
245-
message: "Missing space around operator"
246-
severity: warning
247-
match_kinds:
248-
- argument
249-
- attribute.builtin
250-
- attribute.id
251-
- buildconfig.id
252-
- buildconfig.keyword
253-
- identifier
254-
- keyword
255-
- number
256-
- objectliteral
257-
- parameter
258-
- placeholder
259-
- typeidentifier
260259
missing_empty_line:
261260
name: "Missing Empty Line"
262261
regex: '(?-smxi)(\}\n)([ \t]*?)([^\n\}\t ])'

0 commit comments

Comments
 (0)