added new swiftlint rules

This commit is contained in:
Maxim Sorokin 2020-04-08 17:30:01 +03:00
parent bc3f122966
commit b2460f0683
1 changed files with 42 additions and 0 deletions

View File

@ -222,4 +222,46 @@ custom_rules:
regex: '(^\s*\w*\.?)(addSubview)\([\w]+\)\n\1\2'
message: "Replace multiple addSubview calls with single addSubviews."
severity: warning
getter_setter_style:
name: "Wrong getter/setter code style"
regex: "(get|set|willSet|didSet) \\{ [.]*"
match_kinds:
- keyword
message: "Make a new line break when use getter or setter"
severity: error
boolean_redundant_condition:
name: "Redundant Boolean Condition"
regex: "(== true)|(== false)|(!= true)|(!= false)"
message: "Comparing a boolean to true is redundant (use `?? false` for optionals), and `!`-syntax is preferred over comparing to false."
severity: error
final_class:
name: "Final Class"
regex: "(?<!final )class (?!(\\{|private|func|var))"
message: "Classes without subclasses should be marked as `final`."
match_kinds:
- identifier
- keyword
- typeidentifier
severity: error
closing_brace_vertical_spacing:
name: "Closing Brace Vertical Spacing"
regex: "\\n{2,}\\}"
message: "Closing braces should not be followed by a new line before another closing brace."
severity: error
# Custom rule violating when type inference is not used.
# Violating:
# let view: UIView = UIView()
# view.backgroundColor = UIColor.red()
# Non-violating:
# let view = UIView()
# view.backgroundColor = .red
type_inferred_context:
name: "type_inferred_context"
regex: "(\\:\\s(\\w+)\\s\\=\\s\\1|UIViewAutoResizing\\.|(?!AttributedStringKey.\\.\\*)UIFont\\.|UIControlState\\.|UIColor.\\.\\*(?!.cgColor)|CGPoint\\.|CGRect\\.)"
message: "Type inferred context is preferred over explicit types."
severity: warning