Skip to content

scalafmt rewrites scala 2 syntax into scala 3 in build.sbt file #3787

@mtomko

Description

@mtomko

Configuration (required)

See https://github.com/mtomko/scalafmt-repro2

Please paste the contents of your .scalafmt.conf file here:

version=3.8.0
runner.dialect = scala3
rewrite.scala3.removeOptionalBraces = true

Command-line parameters (required)

When I run scalafmt via CLI like this: scalafmt

Steps

Given code like this:

ThisBuild / scalaVersion := "3.3.1"

lazy val versions = new {
  val cats = "2.10.0"
}

libraryDependencies += "org.typelevel" %% "cats-core" % versions.cats

Problem

Scalafmt formats code like this:

ThisBuild / scalaVersion := "3.3.1"

lazy val versions = new:
  val cats = "2.10.0"

libraryDependencies += "org.typelevel" %% "cats-core" % versions.cats

Expectation

I would like the formatted output to look like this:

ThisBuild / scalaVersion := "3.3.1"

lazy val versions = new {
  val cats = "2.10.0"
}

libraryDependencies += "org.typelevel" %% "cats-core" % versions.cats

Notes

Briefly discussed on discord: https://discord.com/channels/632642981228314653/632665341864181780/1209538770303721533

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions