From 3b7b5616443ede7e3fe3bd9fa316a06e266c2a9b Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Sat, 30 Mar 2024 07:36:03 -0700 Subject: [PATCH] scalafmt: enable SortModifiers with `styleGuide` --- .scalafmt.conf | 6 ++++++ .../src/main/scala/org/scalafmt/config/FormatEvent.scala | 2 +- .../src/main/scala/org/scalafmt/config/ProjectFiles.scala | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index f39cc1b7fb..b648fd22b4 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -14,6 +14,12 @@ align { newlines { avoidForSimpleOverflow = [punct, slc, tooLong] } +rewrite { + rules = [ + SortModifiers, + ] + sortModifiers.preset = styleGuide +} # Disabled in default since this operation is potentially # dangerous if you define your own stripMargin with different # semantics from the stdlib stripMargin. diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/config/FormatEvent.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/config/FormatEvent.scala index f32e3f42ff..c96874c589 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/config/FormatEvent.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/config/FormatEvent.scala @@ -8,7 +8,7 @@ import org.scalafmt.internal.State /** An event that happens while formatting a file. */ -abstract sealed class FormatEvent +sealed abstract class FormatEvent object FormatEvent { case class CreateFormatOps(formatOps: FormatOps) extends FormatEvent diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/config/ProjectFiles.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/config/ProjectFiles.scala index a7f18cf0d3..314a913074 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/config/ProjectFiles.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/config/ProjectFiles.scala @@ -166,7 +166,7 @@ object ProjectFiles { private[config] val s213 = nd(NamedDialect.scala213) private[config] val s3 = nd(NamedDialect.scala3) - protected[config] override def getDialectByLang(lang: String)(implicit + override protected[config] def getDialectByLang(lang: String)(implicit dialect: Dialect ): Option[NamedDialect] = lang match { case "scala-2.10" if is211 => s210