Skip to content

Releases

0.64.6

Choose a tag to compare

@nicklockwood nicklockwood released this 06 Nov 08:39
  • Fixed parsing of value generic parameters, negative integer arguments, integer constraints, and inline-array types
  • Fixed opaqueGenericParameters and simplifyGenericConstraints producing invalid code when formatting value generics
  • Updated redundantSelf to preserve self in Logger calls by default, and made --self-required extend the default list
  • Fixed organizeDeclarations and docComments separating 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 preferSwiftTesting converting 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 singlePropertyPerLine splitting tuple destructuring when the value count does not match
  • Fixed redundantSendable removing Sendable from @usableFromInline types
  • Fixed redundantClosure removing trailing closure arguments followed by a call
  • Fixed handling of unsafe expressions in braces, redundantClosure, redundantParens, and unusedArguments
  • Fixed numberFormatting grouping digits in availability version numbers
  • Fixed trailingCommas adding commas to #warning, #error, and other directives
  • Fixed hoistTry and hoistAwait joining keywords to preceding keywords
  • Fixed yodaConditions corrupting comparisons wrapped after the operator or containing macro calls
  • Fixed redundantInit removing .init when a function parameter shadows the type name
  • Fixed redundantBackticks removing required backticks from type members named Protocol
  • Fixed opaqueGenericParameters introducing some inside generic arguments of closure typealiases
  • Fixed redundantParens removing required parentheses around optional opaque protocol compositions
  • Fixed extensionAccessControl hoisting fileprivate onto extensions of private types
  • Fixed duplicateImports removing imports with different SPI names
  • Fixed preferExplicitFalse breaking parenthesized conditional compilation conditions
  • Fixed preferLazyMap making closures that capture inout values escape

0.64.5

Choose a tag to compare

@nicklockwood nicklockwood released this 31 Oct 16:45
  • Fixed filtered config sections applying to files that do not match, and made matching sections apply in order
  • Improved handling of unsafe in for loops and expression parsing
  • Fixed unusedArguments removing arguments referenced by lifetime attributes
  • Fixed redundantEquatable removing == when stored properties are conditionally compiled
  • Fixed preferForLoop converting forEach calls used as expressions
  • Fixed noForceUnwrapInTests converting force unwraps inside key paths
  • Fixed hoistTry placement around comments, member chains after closures, and multiline declarations
  • Fixed environmentEntry placing default values after attributes on separate lines
  • Fixed braces joining closure statements onto preceding closing braces
  • Fixed redundantClosure treating parentheses on a new line as a call
  • Fixed redundantReturn removing early returns in branches ending with throw
  • Fixed extensionAttributes doubling comment indentation after removed attributes
  • Updated duplicateImports to remove ordinary duplicate imports across code boundaries
  • Fixed docComments leaving trailing spaces when converting documentation comments

0.64.4

Choose a tag to compare

@nicklockwood nicklockwood released this 27 Oct 09:17
  • Fixed redundantReturn removing required returns when nested conditional branches all throw
  • Updated nestedIf to flatten nested else { if ... } branches into else if chains
  • 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

Choose a tag to compare

@nicklockwood nicklockwood released this 26 Oct 09:15
  • Fixed andOperator replacing && with commas inside ternary expression branches
  • Fixed trailingClosures attaching a parenthesized closure on a new line to the preceding statement

0.64.2

Choose a tag to compare

@nicklockwood nicklockwood released this 25 Oct 20:17
  • Fixed severe indent performance regression on large arrays of multiline initializers
  • Improved handling of #if directives 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

Choose a tag to compare

@nicklockwood nicklockwood released this 22 Oct 21:30
  • Fixed nestedIf and repeatedGuard losing condition wrapping when merging statements
  • Fixed wrapArguments wrapping condition lists when line breaks occur only inside individual clauses
  • Fixed wrapEnumCases skipping cases declared after a raw value
  • Fixed propertyTypes dropping .init before a force unwrap or trailing closure
  • Fixed redundantReturn removing required bare returns from do throws(...) bodies
  • Fixed redundantSelf missing local variables declared after a trailing closure
  • Fixed redundantOverload removing overloads in types that declare a conformance
  • Fixed braces moving opening braces onto conditional compilation directive lines
  • Improved indentation and wrapping of multiline if and guard conditions

0.64.0

Choose a tag to compare

@nicklockwood nicklockwood released this 16 Oct 22:27
  • Added --snapshot feature for incrementally adopting formatting without changing files that match a saved snapshot
  • Added --unknown-options error|warn|ignore for handling unknown rules, options, and unsupported option values
  • Added --color auto|always|never to control colored command-line output
  • Added nestedIf rule to merge nested if statements
  • Added repeatedGuard rule to merge consecutive guard statements with identical bodies
  • Added redundantEnumerated rule to remove unused enumeration indices from for loops
  • Added extensionAttributes rule to hoist common member attributes onto extensions
  • Added contentBuilder rule, replacing redundantViewBuilder, with --content-builder and --prefer-content-builder options
  • Added commonTypos rule, with --typo-visibility, --typos, and --ignore-typos options
  • Added forWhere rule with --for-where always|never
  • Added redundantOverload rule to replace forwarding overloads with default arguments
  • Added preferStructSwiftTestingSuites rule
  • Added wrapClosureBodies, wrapDoBodies, and wrapSingleLineStrings rules
  • Added header-creation-date-after: config filters for applying rules based on file header dates
  • Added --scope-blank-lines remove|preserve for function bodies, closures, and statement blocks
  • Added --wrap-single-line-enum-cases option, defaulting to false
  • Added --acronym-visibility option, defaulting to internal
  • Added --blank-line-after-switch-case never option
  • Added --hoist-imports hoist|preserve option, defaulting to hoist
  • Added --excluded-declaration-types option for the docComments rule
  • Added attributes-last import grouping and made import grouping order configurable
  • Added support for sorting array and dictionary literals with swiftformat:sort directives
  • Updated SwiftUI rules to support @ContentBuilder
  • Updated redundantExtendedLifetime to handle write-only references and underscored assignments
  • Updated redundantParens to handle optional opaque types in Swift 6.4
  • Updated noForceUnwrapInTests to handle force unwraps on the RHS of operators and place try at the start of the expression
  • Renamed privateStateVariables to privateSwiftUIDynamicProperties and expanded it to other SwiftUI dynamic properties in views and view modifiers
  • Fixed noForceUnwrapInTests using stale function body ranges and placing try before assignment targets
  • Fixed indentation of multiline conditions, method chains, closures, and wrapped case patterns
  • Fixed redundantSelf and redundantStaticSelf modifying code outside the requested line range
  • Fixed redundantReturn removing required returns before expressions in Void functions
  • Fixed formatting of read and modify accessors
  • Fixed directive handling performance with multiline strings
  • Fixed organizeDeclarations timeouts when declarations share a line
  • Fixed crash in organizeDeclarations rule 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, and DerivedData directories 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

Choose a tag to compare

@nicklockwood nicklockwood released this 30 Sep 07:12
  • Added --locale option for deterministic sorting
  • Added --boolean-guards-in-tests option, defaulting to preserve
  • Updated the default modifier order for convenience to match Apple conventions
  • Fixed sortDeclarations handling of trailing whitespace and comments
  • Fixed preferSwiftStringAPI modifying replacingOccurrences(of: "", with: ...)
  • Fixed disable:next handling in multiline strings
  • Fixed docComments incorrectly converting nested function comments when preceded by executable code
  • Fixed swiftTestingTestCaseNames removing unnamed argument underscores and pluralized acronyms
  • Fixed sortImports treating package imports as unlabeled
  • Fixed indent adding line-wrap indentation to wrapped function names
  • Fixed indent of wrapped case patterns with --indent-case true
  • Fixed preferSwiftTesting adding duplicate default suite attributes
  • Fixed hoistTry placement across infix expressions with trailing closures
  • Fixed building the project with Xcode 27

0.63.0

Choose a tag to compare

@calda calda released this 30 Aug 19:34
  • Added ifExpressions rule to convert ternaries to if expressions
  • Added preferLazyMap rule
  • Added redundantExtendedLifetime rule
  • Added <!-- no-format --> HTML comment syntax for disabling formatting of markdown code blocks
  • Added warning when --enable is used for a rule that is already enabled by default
  • Added --redundant-optional-binding option, defaulting to same-name-only
  • Made --wrapstringinterpolation preserve the default
  • Changed default of --single-line-ternary to convert
  • Distinguished default, opt-in, and deprecated rules in --rules and --rule-info output
  • Updated organizeDeclarations to categorize associatedtype declarations as beforeMarks
  • Updated hoistAwait and hoistTry to automatically detect and preserve autoclosures within same file as definition
  • Updated redundantType and propertyTypes to support more ExpressibleByXLiteral types
  • Updated redundantReturn to preserve bare return in closures where removal would create single-expression body
  • Updated redundantOptionalBinding to convert if let x = property to if let property
  • Updated urlMacro rule to support try #require(URL(string:)) pattern
  • Updated redundantBackticks to preserve backticks on Swift Testing @Test functions
  • Updated swiftTestingTestCaseNames to convert backticked names with test prefix or underscores
  • Updated genericExtensions rule to support collection types
  • Updated unusedPrivateDeclarations to preserve properties used in compiler-generated Equatable and Hashable conformances
  • Increased stack size to 1MB for Linux release builds
  • Fixed redundantClosure false positive for if statements with no else branch
  • Fixed spaces around module selectors in generics
  • Fixed preferForLoop incorrectly applying to dollar-prefixed identifiers
  • Fixed blank line before trailing infix operators
  • Fixed swiftTestingTestCaseNames not adding backticks when required
  • Fixed --preserve-acronyms to work as substring match, not just exact identifier match
  • Fixed genericExtensions rule leaving stray comma with additional where conditions
  • Fixed indent dropping switch case body indentation inside #if with --ifdef no-indent
  • Fixed redundantSwiftUIGroup removing Group(subviews:)
  • Fixed redundantReturn removing redundant returns from switch/if inside a flatMap closure
  • Fixed --ifdef no-indent indentation for method chains and directives
  • Fixed environmentEntry edge cases
  • Fixed redundantInternal stripping required internal inside #if in non-internal extensions
  • Fixed indent of trailing closure in method chain member inside #if
  • Fixed spaceAroundParens spurious violations for keyword identifiers after :: module selector

0.62.1

Choose a tag to compare

@calda calda released this 07 Jul 14:57
  • Several rules have been disabled by default: isEmpty, preferContains, preferFirstWhere, preferCountWhere, preferMinOverSorted, preferFlatMap, emptyExtensions
  • Added --guard-like-if-statements option to noGuardInTests rule, defaulting to preserve

Tip

SwiftFormat new has a website: swiftformat.info! Rules documentation is now available at swiftformat.info/rules.

⌂ 换网址