v2.5.0-RC1
TL;DR
This release candidate may be unstable but we will be grateful for early adoption and bug reports. More detailed release notes coming soon with stable release.
- Introduced experimental newlines.source setting
implicitarguments formatting improvedtrailingCommas = multipleintroduced- Aligning improved
- More configuration for literals
Migration Guide
In this release changed default formatting of hex literals and literals in scientific notation. Currently hex digits and e symbol will lowercased. More details is in the documentation. If you don't want large diff after scalafmt update, you can set
literals.hexDigits=unchanged
literals.scientific=unchanged
newlines.alwaysBeforeMultilineDef may seem too aggressive now. You can disable it if you don't like newlines in diff newlines.alwaysBeforeMultilineDef=false.
Usage Improvements
- CLI: add explicit flag --reportError to exit 1 on malformatted code (#1872) @kitbellew
- ScalafmtConfig: allow overriding per file pattern (#1865) @kitbellew
- Error.NoMatchingFiles: don't display a stack trace (#1860) @kitbellew
- ScalafmtConfig: define edition 2020-03 (#1733) @kitbellew
- Sunset editions (#1839) @olafurpg
Formatting Improvements
- #1627 [18]: FormatOps: ignore line breaks in infix expressions (#1855) @kitbellew
- TreeOps: use numParents for nestedApplies/Select (#1859) @kitbellew
- FormatOps: implement recursive findToken method (#1853) @kitbellew
- #1627 [17]: Several fixes for ApplyType, symbolic select, if in case clause (#1849) @kitbellew
- State: clarify how priority is determined (#1850) @kitbellew
- FormatOps: don't start a statement on a comment (#1846) @kitbellew
- TokenOps bugfix: logic for newline on docstring (#1834) @kitbellew
- Hide lambda body squashing under newlines.source=fold (#1832) @poslegm
- #1627 [14]: Router: single-line Defn lambda for fold only (#1810) @kitbellew
- #1627 [13]: Router: ignore line breaks in comma-separated args (#1808) @kitbellew
- #1627 [12]: Router: ignore line breaks in enumerators (#1806) @kitbellew
- #1627 [11]: Router: relax restrictions on breaks within interpolate (#1805) @kitbellew
- #1627 [10]: Router: ignore line breaks in select chains (#1796) @kitbellew
- #1627 [09]: Router: ignore line breaks in case clauses (#1793) @kitbellew
- #1627 [08]: Router: ignore line breaks in annotations (#1792) @kitbellew
- #1627 [07]: FormatOps: ignore line breaks in rhsOptimalToken (#1790) @kitbellew
- #1627 [06]: Router: ignore line breaks for config style apply (#1786) @kitbellew
- Router bugfix: handle implicit consistently (#1789) @kitbellew
- #1627 [05]: Router: ignore line breaks in def/val assignments (#1779) @kitbellew
- #1627 [04]: Router: ignore line breaks in if-else and bodies (#1778) @kitbellew
- Router: modify indent of case clauses consistently (#1776) @kitbellew
- #1627 [03]: Router: newlines.source=unfold for semicolons (#1774) @kitbellew
- #1627 [02]: Router: ignore line breaks for blocks (#1772) @kitbellew
- BestFirstSearch: check optimal token not to overflow (#1771) @kitbellew
- #1627 [01]: ScalafmtConfig: flag to ignore input line breaks (#1765) @kitbellew
- Alignment by right-side expression (#1759) @poslegm
- Align lines with different columns count (#1785) @poslegm
- Align strip margin: allow disabling the alignment (#1837) @kitbellew
- Preserve newlines in for comprehension generators and values (#1795) @poslegm
- Flexible literal formatting (#1857) @poslegm
- Router: remove unnecessary splits cache, used once (#1874) @kitbellew
- RedundantBraces: re-enable general expressions (#1873) @kitbellew
- Router: fix strip margin in interpolated strings (#1870) @kitbellew
- Newlines: allow break after top-level statements (#1864) @kitbellew
- Newlines: implicitParamListModifier to replace two (#1863) @kitbellew
- Router: remove currently unused comma split (#1763) @kitbellew
- VerticalMultiline: check config style (#1696) @kitbellew
- DanglingParentheses: move
excludelist from VerticalMultiline (#1761) @kitbellew - Router: fix #1749, conflict with #1755 (#1760) @kitbellew
- Router: handle implicit in non-vertical-multiline (#1749) @kitbellew
- poorMansTrailingCommasInConfigStyle deprecation (#1758) @poslegm
- FormatWriter: do not rewrite {} => () around Defn (#1757) @kitbellew
- TrailingCommas: add the
multipleoption (#1755) @kitbellew - RedundantBraces: don't rewrite to parens if nested typed func (#1750) @Kit@kitbellew ormatOps: find the exact param group for each "(" (#1745) @kitbellew
- Router: for multiple args, all or one on a line (#1743) @kitbellew
- FormatOps: in one-arg-per-line, handle lbrace case (#1722) @kitbellew
- Split: switch ignoreIf to tag, allows more control (#1737) @kitbellew
- BestFirstSearch: don't retry if didn't optimize (#1738) @kitbellew
Bugfixes
- Fixed AST changes after formatting variant types with symbolic name (#1762) @poslegm
- Router bugfix: extend line break past infix for any block (#1766) @kitbellew
- Router bugfix: regression in statement/comments (#1854) @kitbellew
- "// format: off" enabled for comments, literals, etc. (#1773) @poslegm
- Fixed contradiction between blankLineBeforeDocstring name and value (#1768) @poslegm
- Fixed newlines on NewAnonymous with empty arguments lambda (#1833) @poslegm
- Fixed alignment overriding (#1869) @poslegm
Documentation
- Documentation improvements (#1767) @poslegm
- Document config overriding functionality (#1781) @poslegm
- Dynamic configuration doc moved to "Disabling or customizing formatting" section (#1868) @poslegm
- Release notes for 2.5.0-RC1 to website (#1876) @poslegm
- Documentation: explain
newlines.topLevelStatements(#1866) @kitbellew - #1627 [19]: Documentation: describe
newlines.afterInfix(#1856) @kitbellew - #1627 [15]: Documentation: describe newlines.source (#1847) @kitbellew
- Documentation: add availability for recent params (#1862) @kitbellew
- Fixed unclear example for danglingParentheses in documentation (#1812) @poslegm
- Changelog updated (#1777) @poslegm
- AvoidInfix: simplify, fix incorrect rewrites (#1875) @kitbellew
- literals.* docs (#1867) @poslegm
Build and Code Health
- All tests moved into the scalafmt-tests package (#1807) @dkartashev
- GraalVM Native Image fix (#1791) @poslegm
- Various minor fixes to logging and tests (#1734) @kitbellew
- Test debug: create a debug instance per test (#1735) @kitbellew
- CI moved from Travis to GitHub Actions (#1732) @poslegm
- SBT_OPTS tuning (#1739) @poslegm
- CI tuning (#1751) @poslegm
- Fetch tags on CI (#1770) @poslegm
- All tests enabled on CI (and fixed) (#1784) @poslegm
- Add script to test that a release succeeded (#1782) @olafurpg
- Tests for already fixed SearchStateExploded error (#1527) (#1836) @poslegm
- Compiler warnings enabled (#1843) @poslegm
- Enforce Prettier formatting on markdown sources. (#1840) @olafurpg
- Minor refactoring to prepare for #1627 (#1764) @kitbellew
- #1627 [16]: ScalafmtConfig: refactor checking source errors (#1848) @kitbellew
- Debug: move printing debug info from FormatWriter (#1851) @kitbellew
Dependency Updates
- Scalameta update (#1780) @poslegm
- Upgrade to the latest Metaconfig (#1852) @olafurpg
- Update sbt-native-packager to 1.7.0 (#1827) @scala-steward
- Update sbt-native-packager to 1.6.2 (#1816) @scala-steward
- Update sbt-scalajs to 1.0.1 (#1818) @scala-steward
- Update sbt-mdoc to 2.1.5 (#1820) @scala-steward
- Update scalameta, testkit to 4.3.7 (#1823) @scala-steward
- Update scalafmt-core to 2.4.2 (#1822) @scala-steward
- Update scala-xml to 1.3.0 (#1819) @scala-steward
- Update sbt-mima-plugin to 0.7.0 (#1815) @scala-steward
- Update scalatest to 3.1.1 (#1824) @scala-steward
- Update sbt-scalafmt to 2.3.2 (#1821) @scala-steward
- Update scalatags to 0.8.6 (#1814) @scala-steward
- Update metaconfig-core, ... to 0.9.9 (#1813) @scala-steward