Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable scalafmt #419

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
with:
java-version: "[email protected]"
- uses: coursier/cache-action@v5
- name: Scalafmt
run: sbt scalafmtSbtCheck scalafmtCheckAll
- name: Unit tests
run: sbt test
- name: Scripted tests
Expand Down
25 changes: 25 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version = 3.5.2
runner.dialect = scala212
maxColumn = 120

danglingParentheses.callSite = false
danglingParentheses.ctrlSite = false
danglingParentheses.defnSite = false
docstrings.oneline = fold
docstrings.style = SpaceAsterisk
literals.hexDigits = Upper
literals.scientific = Upper
newlines.afterCurlyLambdaParams = never
newlines.alwaysBeforeElseAfterCurlyIf = false
newlines.beforeCurlyLambdaParams = never
newlines.topLevelStatements = [before]
optIn.forceBlankLineBeforeDocstring = true

rewrite.sortModifiers.order = [
"override", "final", "implicit",
"sealed", "abstract",
"private", "protected",
"open", "opaque", "infix",
"transparent", "inline",
"lazy"
]
79 changes: 45 additions & 34 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
val scalaJSVersion = sys.env.getOrElse("SCALAJS_VERSION", "1.3.0")

lazy val `scalajs-bundler-linker` =
project.in(file("scalajs-bundler-linker"))
project
.in(file("scalajs-bundler-linker"))
.settings(
scalaVersion := "2.12.11",
libraryDependencies += "org.scala-js" %% "scalajs-linker" % scalaJSVersion
)

val `sbt-scalajs-bundler` =
project.in(file("sbt-scalajs-bundler"))
project
.in(file("sbt-scalajs-bundler"))
.enablePlugins(SbtPlugin, BuildInfoPlugin)
.settings(commonSettings)
.settings(
Expand All @@ -23,11 +25,12 @@ val `sbt-scalajs-bundler` =
val () = scriptedDependencies.value
val () = publishLocal.value
val () = (publishLocal in `scalajs-bundler-linker`).value
},
}
)

val `sbt-web-scalajs-bundler` =
project.in(file("sbt-web-scalajs-bundler"))
project
.in(file("sbt-web-scalajs-bundler"))
.enablePlugins(SbtPlugin)
.settings(commonSettings)
.settings(
Expand All @@ -49,14 +52,17 @@ val `sbt-web-scalajs-bundler` =
// plugins. I can not do that in the `doc` project below because the
// scalaVersion is not compatible.
val apiDoc =
project.in(file("api-doc"))
project
.in(file("api-doc"))
.enablePlugins(ScalaUnidocPlugin)
.settings(noPublishSettings: _*)
.settings(
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
"-groups",
"-doc-source-url", s"https://github.com/scalacenter/scalajs-bundler/blob/v${version.value}€{FILE_PATH}.scala",
"-sourcepath", (baseDirectory in ThisBuild).value.absolutePath
"-doc-source-url",
s"https://github.com/scalacenter/scalajs-bundler/blob/v${version.value}€{FILE_PATH}.scala",
"-sourcepath",
(baseDirectory in ThisBuild).value.absolutePath
),
unidocProjectFilter in (ScalaUnidoc, unidoc) := inAnyProject -- inProjects(`scalajs-bundler-linker`)
)
Expand All @@ -65,7 +71,8 @@ val apiDoc =
val ornateTarget = Def.setting(target.value / "ornate")

val manual =
project.in(file("manual"))
project
.in(file("manual"))
.enablePlugins(OrnatePlugin)
.settings(noPublishSettings: _*)
.settings(
Expand All @@ -85,34 +92,38 @@ val manual =
)

val `scalajs-bundler` =
project.in(file("."))
project
.in(file("."))
.settings(noPublishSettings: _*)
.aggregate(`sbt-scalajs-bundler`, `sbt-web-scalajs-bundler`)

inThisBuild(List(
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-encoding", "UTF-8",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture"
),
scmInfo := Some(
ScmInfo(
url("https://github.com/scalacenter/scalajs-bundler"),
"scm:[email protected]:scalacenter/scalajs-bundler.git"
)
),
organization := "ch.epfl.scala",
homepage := Some(url(s"https://github.com/scalacenter/scalajs-bundler")),
licenses := Seq("MIT License" -> url("http://opensource.org/licenses/mit-license.php")),
developers := List(Developer("julienrf", "Julien Richard-Foy", "[email protected]", url("http://julien.richard-foy.fr")))
))
inThisBuild(
List(
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-encoding",
"UTF-8",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture"
),
scmInfo := Some(
ScmInfo(
url("https://github.com/scalacenter/scalajs-bundler"),
"scm:[email protected]:scalacenter/scalajs-bundler.git"
)
),
organization := "ch.epfl.scala",
homepage := Some(url(s"https://github.com/scalacenter/scalajs-bundler")),
licenses := Seq("MIT License" -> url("http://opensource.org/licenses/mit-license.php")),
developers := List(
Developer("julienrf", "Julien Richard-Foy", "[email protected]", url("http://julien.richard-foy.fr")))
))

lazy val commonSettings = List(
scriptedLaunchOpts ++= Seq(
Expand All @@ -122,7 +133,7 @@ lazy val commonSettings = List(
),
scriptedBufferLog := false,
crossSbtVersions := List("1.2.8"),
sbtVersion in pluginCrossBuild := "1.2.8",
sbtVersion in pluginCrossBuild := "1.2.8"
)

lazy val noPublishSettings =
Expand Down
11 changes: 6 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
addSbtPlugin("com.novocode" % "sbt-ornate" % "0.6")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
addSbtPlugin("com.novocode" % "sbt-ornate" % "0.6")
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.6")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet
Loading