Skip to content

Commit

Permalink
Upgraded sbt-tpolecat and removed excludes
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Sep 7, 2023
1 parent 2199464 commit 8107cef
Show file tree
Hide file tree
Showing 25 changed files with 39 additions and 89 deletions.
6 changes: 0 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ lazy val scalaJsDocsVersion = "1.13.1"
lazy val scalaDocsVersion = "3.3.0"
lazy val indigoDocsVersion = "0.14.0"

ThisBuild / tpolecatExcludeOptions := Set(
ScalacOptions.warnNonUnitStatement,
ScalacOptions.warnValueDiscard,
ScalacOptions.warnUnusedImports
)

lazy val commonSettings: Seq[sbt.Def.Setting[_]] = Seq(
version := tyrianVersion,
organization := "io.indigoengine",
Expand Down
1 change: 0 additions & 1 deletion project/AttributeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ object AttributeGen {
def template(moduleName: String, fullyQualifiedPath: String, contents: String): String =
s"""package $fullyQualifiedPath
|
|import tyrian.Tyrian
|import tyrian.Html.*
|import scala.annotation.targetName
|
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.3
sbt.version=1.9.4
24 changes: 12 additions & 12 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
addSbtPlugin("org.xerial.sbt" %% "sbt-sonatype" % "3.9.21")
addSbtPlugin("com.github.sbt" %% "sbt-pgp" % "2.2.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.4")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7")
addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")
addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.3.1")
addSbtPlugin("com.github.sbt" % "sbt-git" % "2.0.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
addSbtPlugin("org.xerial.sbt" %% "sbt-sonatype" % "3.9.21")
addSbtPlugin("com.github.sbt" %% "sbt-pgp" % "2.2.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7")
addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")
addSbtPlugin("com.github.reibitto" % "sbt-welcome" % "0.3.1")
addSbtPlugin("com.github.sbt" % "sbt-git" % "2.0.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")

libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1"
1 change: 0 additions & 1 deletion tyrian-browser-tests/src/test/scala/tyrian/HttpTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tyrian

import cats.effect.IO
import io.circe.HCursor
import io.circe.parser.*
import tyrian.http.*

Expand Down
2 changes: 0 additions & 2 deletions tyrian-chrome-tests/src/test/scala/tyrian/ChromeTests.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package tyrian

import cats.effect.IO
import io.circe.HCursor
import io.circe.parser.*
import tyrian.http.*

class ChromeTests extends munit.CatsEffectSuite {
Expand Down
2 changes: 0 additions & 2 deletions tyrian-firefox-tests/src/test/scala/tyrian/FirefoxTests.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package tyrian

import cats.effect.IO
import io.circe.HCursor
import io.circe.parser.*
import tyrian.http.*

class FirefoxTests extends munit.CatsEffectSuite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package tyrian
import cats.effect.kernel.Async
import org.scalajs.dom.Event
import org.scalajs.dom.EventTarget
import tyrian.Cmd
import tyrian.Sub
import util.Functions

import scala.scalajs.js
Expand Down
4 changes: 0 additions & 4 deletions tyrian-io/src/main/scala/tyrian/TyrianApp.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package tyrian

import cats.effect.IO
import cats.effect.kernel.Async
import cats.effect.kernel.Resource
import cats.effect.unsafe.implicits.global
import tyrian.TyrianAppF
import tyrian.runtime.TyrianRuntime

/** The TyrianApp trait can be extended to conveniently prompt you for all the methods needed for a Tyrian app, as well
* as providing a number of standard app launching methods.
Expand Down
8 changes: 3 additions & 5 deletions tyrian-zio/src/main/scala/tyrian/TyrianApp.scala
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package tyrian

import cats.effect.Async
import cats.effect.kernel.Async
import cats.effect.kernel.Resource
import org.scalajs.dom.window
import tyrian.TyrianAppF
import tyrian.runtime.TyrianRuntime
import zio.Runtime
import zio.Task
import zio.Unsafe

import scala.annotation.nowarn

/** The TyrianApp trait can be extended to conveniently prompt you for all the methods needed for a Tyrian app, as well
* as providing a number of standard app launching methods.
*/
trait TyrianApp[Msg, Model](using Async[Task]) extends TyrianAppF[Task, Msg, Model]:

private val runtime = Runtime.default

@nowarn("msg=discarded")
val run: Task[Nothing] => Unit = runnable =>
Unsafe.unsafe { implicit unsafe =>
runtime.unsafe.fork(runnable)
Expand Down
4 changes: 0 additions & 4 deletions tyrian/js/src/main/scala/tyrian/HotReload.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ package tyrian

import cats.effect.kernel.Async
import org.scalajs.dom
import util.Functions

import scala.concurrent.duration.FiniteDuration
import scala.scalajs.js

/** A very simple mechanism to allow automatic loading and saving of your applications model to local storage. Uses:
*
Expand Down
10 changes: 0 additions & 10 deletions tyrian/js/src/main/scala/tyrian/Location.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
package tyrian

import cats.effect.kernel.Async
import cats.effect.kernel.Resource
import org.scalajs.dom.Element
import org.scalajs.dom.PopStateEvent
import org.scalajs.dom.document
import org.scalajs.dom.window

import scala.scalajs.js
import scala.scalajs.js.annotation._

sealed trait Location:
def locationDetails: LocationDetails
def isInternal: Boolean
Expand Down
3 changes: 0 additions & 3 deletions tyrian/js/src/main/scala/tyrian/Routing.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package tyrian

import cats.effect.kernel.Async
import org.scalajs.dom.window

/** Provides a number of convenience functions to help with routing in simple use-cases. Here the `Location` type is
* typically hidden away and the user is expected to match on the `String` href (if at all).
*/
Expand Down
3 changes: 2 additions & 1 deletion tyrian/js/src/main/scala/tyrian/Sub.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tyrian

import cats.Functor
import cats.effect.kernel.Async
import cats.effect.kernel.Concurrent
import cats.effect.kernel.Fiber
import cats.effect.kernel.Sync
import cats.kernel.Eq
Expand Down Expand Up @@ -223,6 +222,7 @@ object Sub:
/** A subscription that emits a `msg` based on the running time in seconds whenever the browser renders an animation
* frame.
*/
@nowarn("msg=discarded")
def animationFrameTick[F[_]: Async, Msg](id: String)(toMsg: Double => Msg): Sub[F, Msg] =
Sub.make(
id,
Expand All @@ -231,6 +231,7 @@ object Sub:
dom.window.requestAnimationFrame { t =>
cb(Right(toMsg(t / 1000)))
}
()
}
}
)
Expand Down
9 changes: 0 additions & 9 deletions tyrian/js/src/main/scala/tyrian/Tyrian.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
package tyrian

import cats.effect.kernel.Async
import cats.effect.kernel.Ref
import cats.effect.kernel.Resource
import cats.effect.std.Dispatcher
import cats.effect.syntax.all._
import cats.syntax.all._
import fs2.Stream
import fs2.concurrent.Channel
import org.scalajs.dom.Element
import snabbdom.VNode
import tyrian.runtime.ModelHolder
import tyrian.runtime.TyrianRuntime
import tyrian.runtime.TyrianSSR

Expand Down
10 changes: 5 additions & 5 deletions tyrian/js/src/main/scala/tyrian/TyrianAppF.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package tyrian

import cats.effect.kernel.Async
import cats.effect.kernel.Resource
import org.scalajs.dom.DocumentReadyState
import org.scalajs.dom.Element
import org.scalajs.dom.HTMLElement
import org.scalajs.dom.document
import org.scalajs.dom.window
import tyrian.runtime.TyrianRuntime

import scala.annotation.nowarn
import scala.scalajs.js.Promise
import scala.scalajs.js.annotation.*

Expand Down Expand Up @@ -133,11 +132,13 @@ trait TyrianAppF[F[_]: Async, Msg, Model]:
object TyrianAppF:
/** Launch app instances after DOMContentLoaded.
*/
@nowarn("msg=discarded")
def onLoad[F[_]: Async](appDirectory: Map[String, TyrianAppF[F, _, _]]): Unit =
val documentReady = new Promise((resolve, _reject) => {
document.addEventListener("DOMContentLoaded", _ => resolve(()))
if (document.readyState != DocumentReadyState.loading) {
resolve(())
()
}
})
documentReady.`then`(_ => launch[F](appDirectory))
Expand All @@ -148,11 +149,10 @@ object TyrianAppF:
/** Find data-tyrian-app HTMLElements and launch corresponding TyrianAppF instances
*/
def launch[F[_]: Async](appDirectory: Map[String, TyrianAppF[F, _, _]]): Unit =
for {
element <- document.querySelectorAll("[data-tyrian-app]")
} yield {
document.querySelectorAll("[data-tyrian-app]").foreach { element =>
val tyrianAppElement = element.asInstanceOf[HTMLElement]
val tyrianAppName = tyrianAppElement.dataset.get("tyrianApp")

tyrianAppName.flatMap(appDirectory.get) match
case Some(appSupplier) =>
appSupplier.launch(tyrianAppElement, appElementFlags(tyrianAppElement))
Expand Down
10 changes: 8 additions & 2 deletions tyrian/js/src/main/scala/tyrian/http/Http.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import cats.implicits.*
import org.scalajs.dom
import org.scalajs.dom.HttpMethod
import org.scalajs.dom.RequestInit
import org.scalajs.dom.XMLHttpRequest
import org.scalajs.dom.fetch
import tyrian.Cmd

import scala.annotation.targetName
import scala.annotation.nowarn
import scala.scalajs.js
import scala.util.Try

Expand All @@ -36,6 +35,7 @@ object Http:
*/
def send[F[_]: Async, A, Msg](request: Request[A], resultToMessage: Decoder[Msg]): Cmd.Run[F, Msg, Msg] =

@nowarn("msg=discarded")
def fetchTask(abortController: dom.AbortController): F[dom.Response] = Async[F].async_ { callback =>

val requestInit = new RequestInit {}
Expand All @@ -58,12 +58,18 @@ object Http:
fetch(request.url, requestInit)
.`then`(response => callback(Right(response)))
.`catch`(error => callback(Left(errorToThrowable(error))))

()
}

@nowarn("msg=discarded")
def textBodyTask(domResponse: dom.Response): F[String] = Async[F].async_ { callback =>
domResponse
.text()
.`then`(text => callback(Right(text)))
.`catch`(error => callback(Left(errorToThrowable(error))))

()
}

val fullTask = (for {
Expand Down
1 change: 0 additions & 1 deletion tyrian/js/src/main/scala/tyrian/runtime/Rendering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import tyrian.Event
import tyrian.Html
import tyrian.Location
import tyrian.NamedAttribute
import tyrian.Property
import tyrian.PropertyBoolean
import tyrian.PropertyString
import tyrian.RawTag
Expand Down
9 changes: 4 additions & 5 deletions tyrian/js/src/main/scala/tyrian/runtime/TyrianRuntime.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package tyrian.runtime

import cats.data.OptionT
import cats.effect.kernel.Async
import cats.effect.kernel.Ref
import cats.effect.kernel.Resource
import cats.effect.std.AtomicCell
import cats.effect.std.Dispatcher
import cats.effect.std.Queue
import cats.effect.syntax.all.*
import cats.syntax.all.*
import fs2.Stream
import fs2.concurrent.Channel
import org.scalajs.dom
import org.scalajs.dom.Element
import snabbdom.VNode
Expand All @@ -20,6 +15,8 @@ import tyrian.Html
import tyrian.Location
import tyrian.Sub

import scala.annotation.nowarn

object TyrianRuntime:

def apply[F[_], Model, Msg](
Expand Down Expand Up @@ -73,8 +70,10 @@ object TyrianRuntime:
val renderLoop =
val onMsg = (msg: Msg) => dispatcher.unsafeRunAndForget(msgQueue.offer(msg))

@nowarn("msg=discarded")
val requestAnimationFrame = F.async_ { cb =>
dom.window.requestAnimationFrame(_ => cb(Either.unit))
()
}

def redraw(vnode: VNode) =
Expand Down
3 changes: 0 additions & 3 deletions tyrian/js/src/main/scala/tyrian/websocket/WebSocket.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package tyrian.websocket

import cats.effect.kernel.Async
import cats.effect.kernel.Sync
import cats.effect.std.Dispatcher
import cats.effect.syntax.all.*
import cats.syntax.all.*
import fs2.Stream
import fs2.concurrent.Channel
import org.scalajs.dom
import tyrian.Cmd
import tyrian.Sub
import tyrian.websocket.WebSocketEvent
import util.Functions

import scala.concurrent.duration.*
Expand Down
2 changes: 0 additions & 2 deletions tyrian/js/src/test/scala/tyrian/AttrTests.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package tyrian

import org.scalajs.dom.document
import tyrian.Html.*
import tyrian.runtime.TyrianRuntime

class AttrTests extends munit.FunSuite {

Expand Down
3 changes: 0 additions & 3 deletions tyrian/js/src/test/scala/tyrian/CmdLawsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import cats.Id
import cats.kernel.laws.discipline.EqTests
import cats.kernel.laws.discipline.MonoidTests
import cats.laws.discipline.FunctorTests
import cats.syntax.foldable.*
import org.scalacheck.Arbitrary
import org.scalacheck.Cogen
import org.scalacheck.Gen
import org.scalacheck.rng.Seed
import tyrian.runtime.CmdHelper

class CmdLawsTests extends munit.DisciplineSuite {
Expand Down
4 changes: 4 additions & 0 deletions tyrian/js/src/test/scala/tyrian/CmdSubUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package tyrian

import cats.effect.IO

import scala.annotation.nowarn

object CmdSubUtils:

extension [A](cmd: Cmd[IO, A]) def run: IO[A] = runCmd(cmd)
Expand All @@ -21,11 +23,13 @@ object CmdSubUtils:
extension [A](sub: Sub[IO, A]) def run: (Either[Throwable, A] => Unit) => IO[Unit] = runSub(sub)

@SuppressWarnings(Array("scalafix:DisableSyntax.throw"))
@nowarn("msg=discarded")
def runSub[A, Msg](sub: Sub[IO, Msg])(callback: Either[Throwable, A] => Unit): IO[Unit] =
sub match
case s: Sub.Observe[IO, A, Msg] @unchecked =>
s.observable.map { run =>
run(callback)
()
}

case _ =>
Expand Down
2 changes: 0 additions & 2 deletions tyrian/js/src/test/scala/tyrian/HtmlTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package tyrian

import tyrian.Html.*

import scala.annotation.targetName

class HtmlTests extends munit.FunSuite {

test("'draggable' attribute can have different types") {
Expand Down
Loading

0 comments on commit 8107cef

Please sign in to comment.