Since I've not found anywhere that describes the default settings of swift-format
other than the code, I've pulled those settings out and presented them here.
Rules that are opt-in are marked as such.
(Most of these rules are defined in the default config, not the rules folder.)
- maximumBlankLines = 1
- lineLength = 100
- tabWidth = 8
- indentation = .spaces(2)
- respectsExistingLineBreaks = true
- lineBreakBeforeControlFlowKeywords = false
- lineBreakBeforeEachArgument = false
- lineBreakBeforeEachGenericRequirement = false
- prioritizeKeepingFunctionOutputTogether = false
- indentConditionalCompilationBlocks = true
- lineBreakAroundMultilineExpressionChainComponents = false
- indentSwitchCaseLabels = false
- spacesAroundRangeFormationOperators = false
- UseEarlyExits = false (Opt-In)
You can find the code that defines all these rules in the SwiftFormatRules source folder.
- AllPublicDeclarationsHaveDocumentation = false (Opt-In)
- AlwaysUseLowerCamelCase = true
- AmbiguousTrailingClosureOverload = true
- BeginDocumentationCommentWithOneLineSummary = false (Opt-In)
- DontRepeatTypeInStaticProperties = true
- FileScopedDeclarationPrivacy = true
- IdentifiersMustBeASCII = true
- NeverForceUnwrap = false (Opt-In)
- NeverUseForceTry = false (Opt-In)
- NeverUseImplicitlyUnwrappedOptionals = false (Opt-In)
- NoBlockComments = true
- NoLeadingUnderscores = false (Opt-In)
- OnlyOneTrailingClosureArgument = true
- UseLetInEveryBoundCaseVariable = true
- UseShorthandTypeNames = true
- UseSynthesizedInitializer = true
- ValidateDocumentationComments = false (Opt-In)
Rules that are used by both the formatter and linter.
You can find the code that defines all these rules in the SwiftFormatRules source folder.
- DoNotUseSemicolons = true
- fileScopedDeclarationPrivacy = .private
- FullyIndirectEnum = true
- GroupNumericLiterals = true
- NoAccessLevelOnExtensionDeclaration = true
- NoAssignmentInExpressions = true
- NoCasesWithOnlyFallthrough = true
- NoEmptyTrailingClosureParentheses = true
- NoLabelsInCasePatterns = true
- NoParensAroundConditions = true
- NoVoidReturnOnFunctionSignature = true
- OneCasePerLine = true
- OneVariableDeclarationPerLine = true
- OrderedImports = true
- ReturnVoidInsteadOfEmptyTuple = true
- UseShorthandTypeNames = true
- UseSingleLinePropertyGetter = true
- UseTripleSlashForDocumentationComments = true
- UseWhereClausesInForLoops = false (Opt-In)