I have a Swift project in which is used swiftlint
and my local version is 0.50.03
.
My problem is with styling on closure after running swiftlint lint --fix --format
command.
Here is the scenario:
I have a closure that will be formatted like this after applying Xcode formatting rules (cmd + I)
:
ASStoreManager.shared.makeRegisterAPIRequest(withEmail: emailInputView.formattedText,
withPassword: passwordInputView.formattedText,
withFullName: fullNameInputView.formattedText,
completion: { errors in
ASLoaderUtils.shared.hide()
if let errors = errors {
ASAlertUtils.shared.presentAlert(withErrors: errors)
} else {
ASFirebaseManager.logEvent(withEventName: ASFirebaseConstants.Events.User.signUp,
withParameters: ASFirebaseManager.getUserParameters())
let viewController = ASConfirmationViewController(withConfirmationViewControllerType: .Register)
viewController.callbacks.buttonDidTap = {
ASStoreManager.shared.makeLogIn()
}
let navigationController = viewController.embedToNavigationController()
navigationController.modalPresentationStyle = .fullScreen
self.present(navigationController, animated: true)
}
})
After running the swiftlint
command will be formatted like this:
ASStoreManager.shared.makeRegisterAPIRequest(withEmail: emailInputView.formattedText,
withPassword: passwordInputView.formattedText,
withFullName: fullNameInputView.formattedText,
completion: { errors in
ASLoaderUtils.shared.hide()
if let errors = errors {
ASAlertUtils.shared.presentAlert(withErrors: errors)
} else {
ASFirebaseManager.logEvent(withEventName: ASFirebaseConstants.Events.User.signUp,
withParameters: ASFirebaseManager.getUserParameters())
let viewController = ASConfirmationViewController(withConfirmationViewControllerType: .Register)
viewController.callbacks.buttonDidTap = {
ASStoreManager.shared.makeLogIn()
}
let navigationController = viewController.embedToNavigationController()
navigationController.modalPresentationStyle = .fullScreen
self.present(navigationController, animated: true)
}
})
I tried with the next swiftlint configurations params
in both disabled_rules & opt_in_rules
or just in opt_in_rules
or just in disabled_rules
but nothing is working from stopping swiftlint
to format my closure style:
disabled_rules:
- closure_body_length
- closure_end_indentation
- closure_parameter_position
- closure_spacing
- multiple_closures_with_trailing_closure
- trailing_closure
opt_in_rules:
- closure_body_length
- closure_end_indentation
- closure_parameter_position
- closure_spacing
- multiple_closures_with_trailing_closure
- trailing_closure
My question: How can I stop swiftlint
from formatting my closure and keep the Xcode format style
?