This plugin lets you enforce strict linting rules and iterate quickly in IntelliJ at the same time.
Configure your build with sbt-tpolecat to prevent unused imports, unused parameters etc. to reach main
. Adding the plugin below causes the following behavior:
- All linters are enforced in
sbt
- The
-Wunused:*
flags are not enforced in IntelliJ
// File: ~/.sbt/1.0/plugins/DisableLintersIntelliJ.scala
package localsbt
import sbt.{AutoPlugin, Def, Plugins}
import sbt.Keys._
import sbt.plugins.JvmPlugin
import scala.util.Try
object DisableLintersIntelliJ extends AutoPlugin {
override def trigger = allRequirements
override def requires = {
Try(Class.forName("io.github.davidgregory084.TpolecatPlugin$"))
.map(_.asInstanceOf[Plugins])
.getOrElse(JvmPlugin)
}
override def projectSettings: Seq[Def.Setting[_]] = Seq(
scalacOptions --= {
if (System.getProperty("idea.managed") == "true")
Seq(
"-Wunused:implicits",
"-Wunused:explicits",
"-Wunused:imports",
"-Wunused:locals",
"-Wunused:params",
"-Wunused:patvars",
"-Wunused:privates"
) else Seq.empty
}
)
}