Repository navigation
Releases
Releases · nicklockwood/SwiftFormat
0.64.6
- Fixed parsing of value generic parameters, negative integer arguments, integer constraints, and inline-array types
- Fixed
opaqueGenericParametersandsimplifyGenericConstraintsproducing invalid code when formatting value generics - Updated
redundantSelfto preserveselfin Logger calls by default, and made--self-requiredextend the default list - Fixed
organizeDeclarationsanddocCommentsseparating conditional attributes and documentation from their declarations - Fixed custom prefix
/operators being mistaken for regex literals and causing incorrect lint line numbers - Fixed parsing of tuple types containing parameter pack expansions
- Fixed Xcode-style indentation of wrapped type conformances
- Fixed
preferSwiftTestingconverting XCTest cases with conditionally compiled overrides or references to Swift Testing type names - Updated test suite rules to preserve open classes that may be subclassed
- Fixed
singlePropertyPerLinesplitting tuple destructuring when the value count does not match - Fixed
redundantSendableremovingSendablefrom@usableFromInlinetypes - Fixed
redundantClosureremoving trailing closure arguments followed by a call - Fixed handling of
unsafeexpressions inbraces,redundantClosure,redundantParens, andunusedArguments - Fixed
numberFormattinggrouping digits in availability version numbers - Fixed
trailingCommasadding commas to#warning,#error, and other directives - Fixed
hoistTryandhoistAwaitjoining keywords to preceding keywords - Fixed
yodaConditionscorrupting comparisons wrapped after the operator or containing macro calls - Fixed
redundantInitremoving.initwhen a function parameter shadows the type name - Fixed
redundantBackticksremoving required backticks from type members namedProtocol - Fixed
opaqueGenericParametersintroducingsomeinside generic arguments of closure typealiases - Fixed
redundantParensremoving required parentheses around optional opaque protocol compositions - Fixed
extensionAccessControlhoistingfileprivateonto extensions of private types - Fixed
duplicateImportsremoving imports with different SPI names - Fixed
preferExplicitFalsebreaking parenthesized conditional compilation conditions - Fixed
preferLazyMapmaking closures that captureinoutvalues escape
0.64.5
- Fixed filtered config sections applying to files that do not match, and made matching sections apply in order
- Improved handling of
unsafein for loops and expression parsing - Fixed
unusedArgumentsremoving arguments referenced by lifetime attributes - Fixed
redundantEquatableremoving==when stored properties are conditionally compiled - Fixed
preferForLoopconvertingforEachcalls used as expressions - Fixed
noForceUnwrapInTestsconverting force unwraps inside key paths - Fixed
hoistTryplacement around comments, member chains after closures, and multiline declarations - Fixed
environmentEntryplacing default values after attributes on separate lines - Fixed
bracesjoining closure statements onto preceding closing braces - Fixed
redundantClosuretreating parentheses on a new line as a call - Fixed
redundantReturnremoving early returns in branches ending withthrow - Fixed
extensionAttributesdoubling comment indentation after removed attributes - Updated
duplicateImportsto remove ordinary duplicate imports across code boundaries - Fixed
docCommentsleaving trailing spaces when converting documentation comments
0.64.4
- Fixed
redundantReturnremoving required returns when nested conditional branches all throw - Updated
nestedIfto flatten nestedelse { if ... }branches intoelse ifchains - Fixed command-line handling of paths after the
--end-of-options separator - Fixed CLI warning tests hanging while waiting for stdin when run in isolation
0.64.3
- Fixed
andOperatorreplacing&&with commas inside ternary expression branches - Fixed
trailingClosuresattaching a parenthesized closure on a new line to the preceding statement
0.64.2
- Fixed severe
indentperformance regression on large arrays of multiline initializers - Improved handling of
#ifdirectives in single-expression bodies, including return removal and SwiftUI formatting - Fixed unreachable-code warnings when building JSON encoding code with newer Swift versions
- Fixed Windows release build setup
0.64.1
- Fixed
nestedIfandrepeatedGuardlosing condition wrapping when merging statements - Fixed
wrapArgumentswrapping condition lists when line breaks occur only inside individual clauses - Fixed
wrapEnumCasesskipping cases declared after a raw value - Fixed
propertyTypesdropping.initbefore a force unwrap or trailing closure - Fixed
redundantReturnremoving required bare returns fromdo throws(...)bodies - Fixed
redundantSelfmissing local variables declared after a trailing closure - Fixed
redundantOverloadremoving overloads in types that declare a conformance - Fixed
bracesmoving opening braces onto conditional compilation directive lines - Improved indentation and wrapping of multiline
ifandguardconditions
0.64.0
- Added
--snapshotfeature for incrementally adopting formatting without changing files that match a saved snapshot - Added
--unknown-options error|warn|ignorefor handling unknown rules, options, and unsupported option values - Added
--color auto|always|neverto control colored command-line output - Added
nestedIfrule to merge nested if statements - Added
repeatedGuardrule to merge consecutive guard statements with identical bodies - Added
redundantEnumeratedrule to remove unused enumeration indices from for loops - Added
extensionAttributesrule to hoist common member attributes onto extensions - Added
contentBuilderrule, replacingredundantViewBuilder, with--content-builderand--prefer-content-builderoptions - Added
commonTyposrule, with--typo-visibility,--typos, and--ignore-typosoptions - Added
forWhererule with--for-where always|never - Added
redundantOverloadrule to replace forwarding overloads with default arguments - Added
preferStructSwiftTestingSuitesrule - Added
wrapClosureBodies,wrapDoBodies, andwrapSingleLineStringsrules - Added
header-creation-date-after:config filters for applying rules based on file header dates - Added
--scope-blank-lines remove|preservefor function bodies, closures, and statement blocks - Added
--wrap-single-line-enum-casesoption, defaulting tofalse - Added
--acronym-visibilityoption, defaulting tointernal - Added
--blank-line-after-switch-case neveroption - Added
--hoist-imports hoist|preserveoption, defaulting tohoist - Added
--excluded-declaration-typesoption for thedocCommentsrule - Added
attributes-lastimport grouping and made import grouping order configurable - Added support for sorting array and dictionary literals with
swiftformat:sortdirectives - Updated SwiftUI rules to support
@ContentBuilder - Updated
redundantExtendedLifetimeto handle write-only references and underscored assignments - Updated
redundantParensto handle optional opaque types in Swift 6.4 - Updated
noForceUnwrapInTeststo handle force unwraps on the RHS of operators and placetryat the start of the expression - Renamed
privateStateVariablestoprivateSwiftUIDynamicPropertiesand expanded it to other SwiftUI dynamic properties in views and view modifiers - Fixed
noForceUnwrapInTestsusing stale function body ranges and placingtrybefore assignment targets - Fixed indentation of multiline conditions, method chains, closures, and wrapped case patterns
- Fixed
redundantSelfandredundantStaticSelfmodifying code outside the requested line range - Fixed
redundantReturnremoving required returns before expressions in Void functions - Fixed formatting of
readandmodifyaccessors - Fixed directive handling performance with multiline strings
- Fixed
organizeDeclarationstimeouts when declarations share a line - Fixed crash in
organizeDeclarationsrule when opening brace line has a trailing comment - Improved formatting performance and reduced repeated parsing and configuration work
- Preserved unchanged editor lines when formatting in Xcode
- SwiftFormat now excludes
.build,Build, andDerivedDatadirectories from formatting/linting by default - Removed CocoaPods distribution and the prebuilt binary from the repository (use Swift Package Manager or release downloads instead)
0.63.1
- Added
--localeoption for deterministic sorting - Added
--boolean-guards-in-testsoption, defaulting topreserve - Updated the default modifier order for
convenienceto match Apple conventions - Fixed
sortDeclarationshandling of trailing whitespace and comments - Fixed
preferSwiftStringAPImodifyingreplacingOccurrences(of: "", with: ...) - Fixed
disable:nexthandling in multiline strings - Fixed
docCommentsincorrectly converting nested function comments when preceded by executable code - Fixed
swiftTestingTestCaseNamesremoving unnamed argument underscores and pluralized acronyms - Fixed
sortImportstreatingpackageimports as unlabeled - Fixed
indentadding line-wrap indentation to wrapped function names - Fixed
indentof wrapped case patterns with--indent-case true - Fixed
preferSwiftTestingadding duplicate default suite attributes - Fixed
hoistTryplacement across infix expressions with trailing closures - Fixed building the project with Xcode 27
0.63.0
- Added
ifExpressionsrule to convert ternaries to if expressions - Added
preferLazyMaprule - Added
redundantExtendedLifetimerule - Added
<!-- no-format -->HTML comment syntax for disabling formatting of markdown code blocks - Added warning when
--enableis used for a rule that is already enabled by default - Added
--redundant-optional-bindingoption, defaulting tosame-name-only - Made
--wrapstringinterpolation preservethe default - Changed default of
--single-line-ternarytoconvert - Distinguished default, opt-in, and deprecated rules in
--rulesand--rule-infooutput - Updated
organizeDeclarationsto categorize associatedtype declarations as beforeMarks - Updated
hoistAwaitandhoistTryto automatically detect and preserve autoclosures within same file as definition - Updated
redundantTypeandpropertyTypesto support moreExpressibleByXLiteraltypes - Updated
redundantReturnto preserve barereturnin closures where removal would create single-expression body - Updated
redundantOptionalBindingto convertif let x = propertytoif let property - Updated
urlMacrorule to supporttry #require(URL(string:))pattern - Updated
redundantBackticksto preserve backticks on Swift Testing@Testfunctions - Updated
swiftTestingTestCaseNamesto convert backticked names with test prefix or underscores - Updated
genericExtensionsrule to support collection types - Updated
unusedPrivateDeclarationsto preserve properties used in compiler-generatedEquatableandHashableconformances - Increased stack size to 1MB for Linux release builds
- Fixed
redundantClosurefalse positive for if statements with no else branch - Fixed spaces around module selectors in generics
- Fixed
preferForLoopincorrectly applying to dollar-prefixed identifiers - Fixed blank line before trailing infix operators
- Fixed
swiftTestingTestCaseNamesnot adding backticks when required - Fixed
--preserve-acronymsto work as substring match, not just exact identifier match - Fixed
genericExtensionsrule leaving stray comma with additional where conditions - Fixed
indentdropping switch case body indentation inside#ifwith--ifdef no-indent - Fixed
redundantSwiftUIGroupremovingGroup(subviews:) - Fixed
redundantReturnremoving redundant returns from switch/if inside a flatMap closure - Fixed
--ifdef no-indentindentation for method chains and directives - Fixed
environmentEntryedge cases - Fixed
redundantInternalstripping required internal inside#ifin non-internal extensions - Fixed indent of trailing closure in method chain member inside
#if - Fixed
spaceAroundParensspurious violations for keyword identifiers after::module selector
0.62.1
- Several rules have been disabled by default:
isEmpty,preferContains,preferFirstWhere,preferCountWhere,preferMinOverSorted,preferFlatMap,emptyExtensions - Added
--guard-like-if-statementsoption tonoGuardInTestsrule, defaulting topreserve
Tip
SwiftFormat new has a website: swiftformat.info! Rules documentation is now available at swiftformat.info/rules.