Skip to content

Commit

Permalink
add WarnNonUnitStatements plugin to add -Wnonunit-statement option to…
Browse files Browse the repository at this point in the history
… Scala 2.13 builds
  • Loading branch information
bpholt committed Mar 14, 2024
1 parent daa96b1 commit a68fd8d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions project/AsyncUtilsBuildPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.scalajs.jsenv.JSEnv
import org.scalajs.jsenv.nodejs.NodeJSEnv
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport.*
import org.typelevel.sbt.TypelevelMimaPlugin.autoImport.*
import org.typelevel.sbt.TypelevelSettingsPlugin
import org.typelevel.sbt.gha.GenerativePlugin.autoImport.*
import org.typelevel.sbt.mergify.MergifyPlugin
import org.typelevel.sbt.mergify.MergifyPlugin.autoImport.*
Expand All @@ -21,7 +22,7 @@ object AsyncUtilsBuildPlugin extends AutoPlugin {
override def trigger = noTrigger

override def requires: Plugins =
ProjectMatrixPlugin && ScalafixPlugin && MimaPlugin && MergifyPlugin
ProjectMatrixPlugin && ScalafixPlugin && MimaPlugin && MergifyPlugin && TypelevelSettingsPlugin && WarnNonUnitStatements

object autoImport {
lazy val allProjects: Seq[Project] =
Expand Down Expand Up @@ -304,7 +305,6 @@ object AsyncUtilsBuildPlugin extends AutoPlugin {
.dependsOn(`async-utils-finagle`)

override def buildSettings: Seq[Def.Setting[?]] = Seq(
scalaVersion := SCALA_2_13,
mergifyLabelPaths :=
List(
"core",
Expand Down Expand Up @@ -357,3 +357,18 @@ object AsyncUtilsBuildPlugin extends AutoPlugin {
private lazy val nvmJsEnv: TaskKey[JSEnv] = taskKey("use nvm to find node")
private lazy val nodeExecutable: TaskKey[Option[File]] = taskKey("path to Node executable for JS tasks")
}

object WarnNonUnitStatements extends AutoPlugin {
override def trigger = allRequirements

override def projectSettings: Seq[Def.Setting[?]] = Seq(
scalacOptions ++= {
if (scalaVersion.value.startsWith("2.13"))
Seq("-Wnonunit-statement")
else if (scalaVersion.value.startsWith("2.12"))
Seq()
else
Nil
},
)
}

0 comments on commit a68fd8d

Please sign in to comment.