diff --git a/.scalafix.conf b/.scalafix.conf new file mode 100644 index 0000000..a788aa3 --- /dev/null +++ b/.scalafix.conf @@ -0,0 +1,12 @@ +OrganizeImports { + blankLines = Manual + coalesceToWildcardImportThreshold = null + expandRelative = false + groupExplicitlyImportedImplicitsSeparately = false + groupedImports = AggressiveMerge + groups = [ "*" ] + importSelectorsOrder = Ascii + importsOrder = Ascii + preset = DEFAULT + removeUnused = true +} diff --git a/.scalafmt.conf b/.scalafmt.conf index 9a91928..fc23f88 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -7,7 +7,8 @@ maxColumn = 100 indentOperator.preset = "spray" unindentTopLevelOperators = true spaces.inImportCurlyBraces = true -rewrite.rules = ["AsciiSortImports", "RedundantBraces", "RedundantParens"] +rewrite.rules = ["Imports", "RedundantBraces", "RedundantParens"] +rewrite.imports.sort = "ascii" docstrings.blankFirstLine = true trailingCommas = "preserve" newlines.beforeCurlyLambdaParams = "multilineWithCaseOnly" diff --git a/src/main/scala/de/heikoseeberger/sbtfresh/Fresh.scala b/src/main/scala/de/heikoseeberger/sbtfresh/Fresh.scala index d958bdb..c7cef4f 100644 --- a/src/main/scala/de/heikoseeberger/sbtfresh/Fresh.scala +++ b/src/main/scala/de/heikoseeberger/sbtfresh/Fresh.scala @@ -68,7 +68,10 @@ private final class Fresh( def writeReadme(): Path = write("README.md", Template.readme(name, license)) - def writeScalafmt(): Path = + def writeScalafixConf(): Path = + write(".scalafix.conf", Template.scalafixConf) + + def writeScalafmtConf(): Path = write(".scalafmt.conf", Template.scalafmtConf) private def write(path: String, content: String) = diff --git a/src/main/scala/de/heikoseeberger/sbtfresh/FreshPlugin.scala b/src/main/scala/de/heikoseeberger/sbtfresh/FreshPlugin.scala index 068c934..3ee3c77 100644 --- a/src/main/scala/de/heikoseeberger/sbtfresh/FreshPlugin.scala +++ b/src/main/scala/de/heikoseeberger/sbtfresh/FreshPlugin.scala @@ -122,7 +122,8 @@ object FreshPlugin extends AutoPlugin { fresh.writeNotice() fresh.writePlugins() fresh.writeReadme() - fresh.writeScalafmt() + fresh.writeScalafixConf() + fresh.writeScalafmtConf() if (setUpGit) fresh.initialCommit() state.reboot(true) diff --git a/src/main/scala/de/heikoseeberger/sbtfresh/Template.scala b/src/main/scala/de/heikoseeberger/sbtfresh/Template.scala index 188f1cf..e66b398 100644 --- a/src/main/scala/de/heikoseeberger/sbtfresh/Template.scala +++ b/src/main/scala/de/heikoseeberger/sbtfresh/Template.scala @@ -202,6 +202,20 @@ private object Template { |""".stripMargin } + def scalafixConf: String = + """|OrganizeImports { + | blankLines = Manual + | coalesceToWildcardImportThreshold = null + | expandRelative = false + | groupExplicitlyImportedImplicitsSeparately = false + | groupedImports = AggressiveMerge + | groups = [ "*" ] + | importSelectorsOrder = Ascii + | importsOrder = Ascii + | preset = DEFAULT + | removeUnused = true + |}""".stripMargin + def scalafmtConf: String = """|version = "3.3.1" | @@ -212,7 +226,8 @@ private object Template { |indentOperator.preset = "spray" |unindentTopLevelOperators = true |spaces.inImportCurlyBraces = true - |rewrite.rules = ["AsciiSortImports", "RedundantBraces", "RedundantParens"] + |rewrite.rules = ["Imports", "RedundantBraces", "RedundantParens"] + |rewrite.imports.sort = "ascii" |docstrings.blankFirstLine = true |trailingCommas = "preserve" |newlines.beforeCurlyLambdaParams = "multilineWithCaseOnly" diff --git a/src/sbt-test/sbt-fresh/default/test b/src/sbt-test/sbt-fresh/default/test index 44191bb..fa5199f 100644 --- a/src/sbt-test/sbt-fresh/default/test +++ b/src/sbt-test/sbt-fresh/default/test @@ -1,5 +1,6 @@ > fresh organization=org name=acme setUpGit=true $ exists .gitignore +$ exists .scalafix.conf $ exists .scalafmt.conf $ exists build.sbt $ exists LICENSE