Releases: swiftlang/swift-format
Releases Β· swiftlang/swift-format
601.0.0-prerelease-2024-12-17
Change version to 601.0.0-prerelease-2024-12-17
601.0.0-prerelease-2024-12-12
Change version to 601.0.0-prerelease-2024-12-12
601.0.0-prerelease-2024-12-05
Change version to 601.0.0-prerelease-2024-12-05
601.0.0-prerelease-2024-10-15
Change version to 601.0.0-prerelease-2024-10-15
601.0.0-prerelease-2024-10-09
Change version to 601.0.0-prerelease-2024-10-09
601.0.0-prerelease-2024-10-01
Change version to 601.0.0-prerelease-2024-10-01
600.0.0
What's Changed
- Add option to disable trailing commas on multi-line collections by @mlavergn in #619
- [Lint] Add a rule to detect and transform
[<Type>]()
into literal β¦ by @xedin in #617 - Add support for various new 5.9 features. by @allevato in #622
- Disable testable imports when testing swift-format by @ahoppen in #624
- Donβt set
SWIFT_BUILD_SCRIPT_ENVIRONMENT
when building swift-format by @ahoppen in #630 - Add the
UseExplicitNilCheckInConditions
rule. by @allevato in #627 - Add option to print number of instructions executed by
swift-format
by @ahoppen in #625 - Fix building error by @kimdv in #631
- Rename
_InstructionCounter
by @bnbarham in #632 - Fix up import of renamed
_InstructionCount
by @bnbarham in #633 - Fix broken links in docs by @japanese-goblinn in #635
- Allow JSON configuration text to be passed directly on the command line. by @allevato in #634
- Make all
Finding.Message
extensions file-private. by @allevato in #636 - Remove the
SwiftFormatConfiguration
module. by @allevato in #637 - Rename
generate-pipeline
togenerate-swift-format
. by @allevato in #638 - Add installation instructions for Homebrew by @beatrupp in #639
- Fix a bug where an unfolded
SequenceExpr
would make it to the pretty-printer. by @allevato in #641 - Ignore too long end of line comments when they're wrapped in `printCo⦠by @dylansturg in #642
- Don't lose a trailing comma in
UseExplicitNilCheckInConditions
. by @allevato in #645 - Ignore symlinks and hidden (dot) files during
--recursive
. by @allevato in #644 - Remove the legacy trivia workaround. by @allevato in #646
- Add parentheses when needed to convert
let _ = expr
toexpr != nil
. by @allevato in #647 - Various trivia-related fixes. by @allevato in #648
- Some minor frontend tweaks. by @allevato in #649
- [AllPublicDeclarationsHaveDocumentation] Fix behavior for
override
methods. by @allevato in #655 - Fix multi-line string wrapping in
@available
attributes. by @allevato in #656 - Respect SyntaxVisitorContinueKind of rules when run in Pipeline by @thunderseethe in #659
- Remove deprecated variants from parameterClause case match by @thunderseethe in #661
- Various fixes for some 509.0.0 bugs. by @allevato in #666
- [OrderedImports] Fix dropped trailing comments on top-level code items. by @allevato in #674
- Allow cross-compiling swift-format by @ahoppen in #679
- Donβt include the toolchain rpath when installing swift-format by @ahoppen in #680
- Order package manifest to start with the package declaration by @ahoppen in #682
- [CI] Only use 'required' for Python >= 3.7 by @bnbarham in #686
- build: introduce a CMake based build for swift-format by @compnerd in #677
- Clean up rpaths of installed swift-format by @ahoppen in #683
- Ignore sentence terminators inside quotes when applying the 'BeginDocumentationCommentWithOneLineSummary' option. by @TTOzzi in #687
- Find configuration based on CWD when formatting from stdin by @judemille in #685
- fix readme typo by @saturnboy in #688
- Renamed plugin configuration parameter by @dmonagle in #696
- [6.0] Depend on swift-syntax
release/6.0
instead ofmain
by @ahoppen in #706 - Update README to specify version 510.1.0 for building from source by @mh-mobile in #709
- Fix comment for multiElementCollectionTrailingCommas by @ozumin in #710
- Fix some typos by @mrs1669 in #711
- Fix @_originallyDefinedIn argument spacing by @dduan in #717
- Fix incorrect spacing when pretty-printing @_documentation by @dduan in #719
- Merge
main
intorelease/6.0
by @ahoppen in #720 - Update RuleDocumentation.md by @fawkeswei in #727
- Remove check for prioritizeKeepingFunctionOutputTogether on enum decl. by @shawnhyam in #728
- Make sure there is a break after an #endif. by @shawnhyam in #729
- Merge
main
intorelease/6.0
by @ahoppen in #731 - Merge
main
intorelease/6.0
by @ahoppen in #733 - Merge adjacent .line and .docLine comments into a single element. by @shawnhyam in #732
- Merge
main
intorelease/6.0
by @ahoppen in #742 - Support for formatting a selection by @DaveEwing in #708
- Fix
@_expose
attribute argument spacing by @kateinoigakukun in #750 - Handle indented block comments with ASCII art correctly. by @shawnhyam in #746
- Delete CODE_OF_CONDUCT.md by @parispittman in #753
- Update README.md by @parispittman in #755
- Delete CONTRIBUTING.md by @parispittman in #754
- Update links for repositories moved to the swiftlang org on GitHub by @ahoppen in #757
- Update README.md to mention that swift-format is included in Xcode 16 by @ahoppen in #756
- [6.0] Update links for repositories moved to the swiftlang org on GitHub by @ahoppen in #758
- add support for riscv64 by @futurejones in #752
- Merge
main
intorelease/6.0
by @ahoppen in #760 - Fix a build issue in swift-format by @ahoppen in #762
- [6.0] Add a break after
do
when it has typed throws by @bnbarham in #774 - [6.0] Improve formatting of macro decls with attributes by @ahoppen in #781
- [6.0] Fix missing break in nested IfConfig decls by @ahoppen in #782
New Contributors
- @mlavergn made their first contribution in #619
- @japanese-goblinn made their first contribution in #635
- @beatrupp made their first contribution in #639
- @judemille made their first contribution in #685
- @saturnboy made their first contribution in #688
- @dmonagle made their first contribution in #696
- @mh-mobile made their first contribution in #709
- @ozumin made their first contribution in #710
- @mrs1669 made their first contribution in #711
- @fawkeswei made their first contribution in #727
- @DaveEwing made their first contribution in #708
- @kateinoigakukun made their first contribution in #750
- @parispittman made their first contribution in #753
- @futurejones made their first contribution in #752
510.1.0
What's Changed
- Update to non-optional leading/trailingTrivia swift-syntax API by @bnbarham in #497
- Adjustments to split
FunctionParameterSyntax
into multiple nodes for function parameters, closure parameters and enum parameters by @ahoppen in #495 - Prepare 508.0.0 release. by @allevato in #506
- Fix formatting of import with multiple attributes (fixes #445) and ensure that imports never wrap by @stackotter in #501
- Fix fatal error caused by switch cases without any statements (#473) by @stackotter in #499
- Remove the
swift-tools-support-core
dependency from swift-format. by @allevato in #509 - Fix pretty printing of multi-statement closures (issue #494) by @stackotter in #498
- Avoid removing certain disambiguating parens from conditions (fixes #298) by @stackotter in #503
- Fix more postfix pound if scenarios by @DavidBrunow in #402
- Remove usages of functions that shouldnβt be part of SwiftSyntaxβs public API by @ahoppen in #504
- Removed warnings by @CippoX in #510
- Adjustment for SwiftSyntax rename
members
->memberBlock
by @ahoppen in #512 - [SwiftSyntax] Remove force unwrapping for source location by @kimdv in #513
- Change version dependency on
swift-argument-parser
to fromupToNextMinor
toupToNextMajor
by @ahoppen in #517 - Replace deprecated code of swift-syntax with the latest code to remove warning by @TTOzzi in #531
- Fix indentation of multiline strings when part of a larger expression. by @allevato in #532
- Fix
try
/await
expressions inNoAssignmentInExpressions
. by @allevato in #533 - Further improve multiline string formatting. by @allevato in #534
- Allow exceptions to
NoAssignmentInExpressions
. by @allevato in #535 - Add
Token.break
after fixity in operator declaration by @StevenWong12 in #536 - Rename
elementList
inTupleExprSyntax
toelements
by @StevenWong12 in #537 - Fix
async throws
function types when they appear in an expression context. by @allevato in #539 - Replace deprecated code from swift-syntax by @TTOzzi in #540
- Wrap keypath literals appropriately. by @allevato in #545
- Format
macro
declarations. by @allevato in #546 - Insert white space before trailing closure of a macro expression by @kimberninger in #544
- Rename 'squareBracket' to 'square' by @TTOzzi in #541
- Delete
UnknownNodeTests
. by @allevato in #548 - Fix formatting of
@backDeploy
attribute. by @allevato in #550 - Don't insert an extra break inside empty multiline strings. by @allevato in #551
- Downgrade
editor placeholder in source file
from error to warning. by @allevato in #547 - Improve wrapping of if/switch expressions. by @allevato in #553
- Fix postfix-
#if
formatting when they come after a closing parenthesis. by @allevato in #554 - Fix indentation of multiline strings in enum case raw values. by @allevato in #555
- Fix deprecated SwiftSyntax api warnings by @kitasuke in #558
- Remove the compiler condition guarding
DerivativeRegistrationAttributeArgumentsSyntax
. by @allevato in #559 - Use swift-markdown to parse documentation comments. by @allevato in #560
- Adjustment because of a property rename in swift-syntax by @ahoppen in #561
- Replace
[TriviaPiece].Index
withArray<TriviaPiece>.Index
. by @allevato in #565 - Remove --mode flag for configuration dump by @Gray-Wind in #566
- Use newer equivalents of deprecated nodes names by @Matejkob in #567
- Add XCTest exclusion comment for lint rules by @kitasuke in #568
- Use methods on Sequence instead of SyntaxCollection by @kitasuke in #569
- Update swift-format for renamed children in SwiftSyntax by @ahoppen in #562
- Fix deprecated warnings regarding swift-syntax changes by @kitasuke in #570
- Adjustments for node renames in swift-syntax by @ahoppen in #572
- Remove
initializer
fromTupleTypeElementSyntax
initializer call by @ahoppen in #573 - Rename children of differentiability nodes by @ahoppen in #574
- Adjustments for refactoring of representation of Accessors in SwiftSyntax by @ahoppen in #576
- Use
where
instead of filter forfor
loops by @ahoppen in #575 - Adjustments for usage of
DeclReferenceExprSyntax
as child ofMemberAccessExprSyntax
by @ahoppen in #577 - [Core] Add new finding severity kinds -
refactoring
andconvention
by @xedin in #578 - Fix deprecation warnings from renamed nodes / types in SwiftSyntax by @ahoppen in #579
- Move the default
Configuration.init()
into a separate file. by @allevato in #580 - Don't alter doc line comments unnecessarily. by @allevato in #581
- Improve a bunch of diagnostic messages. by @allevato in #583
- Migrate away from the latest deprecated APIs. by @allevato in #584
- Replace the
ReplaceTrivia
rewriter with direct trivia mutations. by @allevato in #588 - Parenthesize
some/any
types when convertingOptional
to?
. by @allevato in #589 - Update for the fact that syntax collections are always non-optional in SwiftSyntax now by @ahoppen in #585
- Make
shebang
a child ofSourceFileSyntax
by @StevenWong12 in #590 - [Lint] Add a rule to detect that type declarations are not capitalized by @xedin in #587
- Don't warn about a redundant synthesized memberwise init if it has attributes. by @allevato in #592
- Collapse almost everything into a single
SwiftFormat
module. by @allevato in #593 - Refactor tests. by @allevato in #595
- Don't do anything if the input is empty. by @allevato in #599
- Fix a bunch of FIXMEs around linter findings. by @allevato in #597
- [Lint/Format] Add a rule to omit
return
from functions, closures, subscripts, and variables by @xedin in #596 - [Lint] Add a rule to replace
.forEach
with a for-in loop by @xedin in #603 - Replace
with
calls with in-place mutation; clean up helpers. by @allevato in #609 - Actually implement
NoPlaygroundLiterals
rule. by @allevato in #613 - Adjust for "remark" diagnostic severity by @DougGregor in #605
- Move
Configuration
into theSwiftFormat
module. by @allevato in #614 - Fix invalid links in README by @woxtu in #594
- Default to all targets when plugin
--target
parameter missing. Fix #483 by @BrianHenryIE in #608 - Remove unnecessary casting by @Matejkob in #618
- Output a warning for unknown configuration rules in
.swift-format
by @natikgadzhi in #612 - Generate rule docs automatically by @natikgadzhi in #615
- [5.10] Add fixes that were present in 509.0.0 but not release/5.10 by @ahoppen in #704
New Contributors
- @stackotter made their first contribution in #501
- @CippoX made their first contribution in #510
- @StevenWong12 ...
509.0.0
This release is compatible with Swift 5.9.
Significant changes since the last release:
New rules
AlwaysUseLiteralForEmptyCollectionInit
: transforms no-argument initializer calls on collection types to use the empty collection literal instead. For example,let x = [Int]()
will be transformed intolet x: [Int] = []
. This rule is opt-in (disabled by default).NoPlaygroundLiterals
: emits lint findings when the playground literals (#colorLiteral
,#fileLiteral
,#imageLiteral
) are used in code. Enabled by default.OmitExplicitReturns
: removes unnecessaryreturn
keywords from single-expression function/closure/subscript/accessor bodies. This rule is opt-in (disabled by default).ReplaceForEachWithForLoop
: emits lint findings when theforEach
method is called with a closure literal at the end of a member access chain, indicating that it should be replaced by afor
loop instead. Enabled by default.TypeNamesShouldBeCapitalized
: emits lint findings when a type is declared with a name that is notUpperCamelCase
. Enabled by default.
New configuration settings
multiElementCollectionTrailingCommas
(boolean): When set tofalse
, the last element of a multi-element array or dictionary literal will not have a trailing comma, even when the literal wraps across multiple lines. Defaults totrue
(preserving the behavior of previous releases).
Bug fixes and behavior changes
- swift-format no longer crashes when formatting a
case
block that contains no statements. - In multi-statement closures, there is now always a line break between the
in
keyword and the first statement. - Attributes before
import
statements are no longer wrapped. - The
NoParensAroundConditions
rule no longer removes parentheses around an immediately called closure. - The
NoAssignmentInExpressions
rule can be configured to ignore assignments that occur inside certain function calls. The default configuration ignores assignments insideXCTAssertNoThrow
. - When an editor placeholder is found in the source, this is now treated as a warning instead of an error. This allows formatting to continue, treating the placeholder as a regular identifier.
- Keypath literals are properly wrapped and indented.
- Postfix-
#if
expressions are no longer indented too far when they follow a closing parenthesis. - Indentation of multiline strings has been fixed in a number of locations.
- Documentation comment parsing has improved for rules like
BeginDocumentationCommentWithOneLineSummary
,UseTripleSlashForDocumentationComments
, andValidateDocumentationComments
. - Diagnostic messages throughout swift-format have been cleaned up and improved.
- The
UseShorthandTypeNames
rule properly parenthesizes optionalsome/any
types; for example,Optional<any P>
becomes(any P)?
, notany P?
(which is invalid). - The
UseSynthesizedInitializer
rule no longer warns that an initializer is redundant if it is declared with any attributes. - The lint/format plugins for SPM now default to processing all targets if the
--target
argument is not specified. - swift-format now emits a warning if you configure a rule that does not exist. This is meant to help catch typos in the configuration file.
- swift-format now does nothing if its input is empty (i.e., a zero-byte file). This suppresses a single trailing newline that would have otherwise been added in this case.
API changes
For developers using swift-format as a library, the types in the SwiftFormatConfiguration
module have been folded into the SwiftFormat
module. The SwiftFormat
module is now the sole module you should import to use the linter/formatter APIs.
The SwiftFormatConfiguration
module still exists to re-export the types for backwards compatibility, but this will be removed in the 510.0.0 release.
Swift 5.10 Release
What's Changed
- Update to non-optional leading/trailingTrivia swift-syntax API by @bnbarham in #497
- Adjustments to split
FunctionParameterSyntax
into multiple nodes for function parameters, closure parameters and enum parameters by @ahoppen in #495 - Prepare 508.0.0 release. by @allevato in #506
- Fix formatting of import with multiple attributes (fixes #445) and ensure that imports never wrap by @stackotter in #501
- Fix fatal error caused by switch cases without any statements (#473) by @stackotter in #499
- Remove the
swift-tools-support-core
dependency from swift-format. by @allevato in #509 - Fix pretty printing of multi-statement closures (issue #494) by @stackotter in #498
- Avoid removing certain disambiguating parens from conditions (fixes #298) by @stackotter in #503
- Fix more postfix pound if scenarios by @DavidBrunow in #402
- Remove usages of functions that shouldnβt be part of SwiftSyntaxβs public API by @ahoppen in #504
- Removed warnings by @CippoX in #510
- Adjustment for SwiftSyntax rename
members
->memberBlock
by @ahoppen in #512 - [SwiftSyntax] Remove force unwrapping for source location by @kimdv in #513
- Change version dependency on
swift-argument-parser
to fromupToNextMinor
toupToNextMajor
by @ahoppen in #517 - Replace deprecated code of swift-syntax with the latest code to remove warning by @TTOzzi in #531
- Fix indentation of multiline strings when part of a larger expression. by @allevato in #532
- Fix
try
/await
expressions inNoAssignmentInExpressions
. by @allevato in #533 - Further improve multiline string formatting. by @allevato in #534
- Allow exceptions to
NoAssignmentInExpressions
. by @allevato in #535 - Add
Token.break
after fixity in operator declaration by @StevenWong12 in #536 - Rename
elementList
inTupleExprSyntax
toelements
by @StevenWong12 in #537 - Fix
async throws
function types when they appear in an expression context. by @allevato in #539 - Replace deprecated code from swift-syntax by @TTOzzi in #540
- Wrap keypath literals appropriately. by @allevato in #545
- Format
macro
declarations. by @allevato in #546 - Insert white space before trailing closure of a macro expression by @kimberninger in #544
- Rename 'squareBracket' to 'square' by @TTOzzi in #541
- Delete
UnknownNodeTests
. by @allevato in #548 - Fix formatting of
@backDeploy
attribute. by @allevato in #550 - Don't insert an extra break inside empty multiline strings. by @allevato in #551
- Downgrade
editor placeholder in source file
from error to warning. by @allevato in #547 - Improve wrapping of if/switch expressions. by @allevato in #553
- Fix postfix-
#if
formatting when they come after a closing parenthesis. by @allevato in #554 - Fix indentation of multiline strings in enum case raw values. by @allevato in #555
- Fix deprecated SwiftSyntax api warnings by @kitasuke in #558
- Remove the compiler condition guarding
DerivativeRegistrationAttributeArgumentsSyntax
. by @allevato in #559 - Use swift-markdown to parse documentation comments. by @allevato in #560
- Adjustment because of a property rename in swift-syntax by @ahoppen in #561
- Replace
[TriviaPiece].Index
withArray<TriviaPiece>.Index
. by @allevato in #565 - Remove --mode flag for configuration dump by @Gray-Wind in #566
- Use newer equivalents of deprecated nodes names by @Matejkob in #567
- Add XCTest exclusion comment for lint rules by @kitasuke in #568
- Use methods on Sequence instead of SyntaxCollection by @kitasuke in #569
- Update swift-format for renamed children in SwiftSyntax by @ahoppen in #562
- Fix deprecated warnings regarding swift-syntax changes by @kitasuke in #570
- Adjustments for node renames in swift-syntax by @ahoppen in #572
- Remove
initializer
fromTupleTypeElementSyntax
initializer call by @ahoppen in #573 - Rename children of differentiability nodes by @ahoppen in #574
- Adjustments for refactoring of representation of Accessors in SwiftSyntax by @ahoppen in #576
- Use
where
instead of filter forfor
loops by @ahoppen in #575 - Adjustments for usage of
DeclReferenceExprSyntax
as child ofMemberAccessExprSyntax
by @ahoppen in #577 - [Core] Add new finding severity kinds -
refactoring
andconvention
by @xedin in #578 - Fix deprecation warnings from renamed nodes / types in SwiftSyntax by @ahoppen in #579
- Move the default
Configuration.init()
into a separate file. by @allevato in #580 - Don't alter doc line comments unnecessarily. by @allevato in #581
- Improve a bunch of diagnostic messages. by @allevato in #583
- Migrate away from the latest deprecated APIs. by @allevato in #584
- Replace the
ReplaceTrivia
rewriter with direct trivia mutations. by @allevato in #588 - Parenthesize
some/any
types when convertingOptional
to?
. by @allevato in #589 - Update for the fact that syntax collections are always non-optional in SwiftSyntax now by @ahoppen in #585
- Make
shebang
a child ofSourceFileSyntax
by @StevenWong12 in #590 - [Lint] Add a rule to detect that type declarations are not capitalized by @xedin in #587
- Don't warn about a redundant synthesized memberwise init if it has attributes. by @allevato in #592
- Collapse almost everything into a single
SwiftFormat
module. by @allevato in #593 - Refactor tests. by @allevato in #595
- Don't do anything if the input is empty. by @allevato in #599
- Fix a bunch of FIXMEs around linter findings. by @allevato in #597
- [Lint/Format] Add a rule to omit
return
from functions, closures, subscripts, and variables by @xedin in #596 - [Lint] Add a rule to replace
.forEach
with a for-in loop by @xedin in #603 - Replace
with
calls with in-place mutation; clean up helpers. by @allevato in #609 - Actually implement
NoPlaygroundLiterals
rule. by @allevato in #613 - Adjust for "remark" diagnostic severity by @DougGregor in #605
- Move
Configuration
into theSwiftFormat
module. by @allevato in #614 - Fix invalid links in README by @woxtu in #594
- Default to all targets when plugin
--target
parameter missing. Fix #483 by @BrianHenryIE in #608 - Remove unnecessary casting by @Matejkob in #618
- Output a warning for unknown configuration rules in
.swift-format
by @natikgadzhi in #612 - Generate rule docs automatically by @natikgadzhi in #615
New Contributors
- @stackotter made their first contribution in #501
- @CippoX made their first contribution in #510
- @StevenWong12 made their first contribution in #536
- @kimberninger made their first contribution in ht...