softwaremill / scala-clippy

Good advice for Scala compiler errors
Apache License 2.0
312 stars 20 forks source link

Help creating advice for scalajs-react #47

Closed japgolly closed 7 years ago

japgolly commented 7 years ago

Hi! I'd like to create some advice for scalajs-react and I'd like to ask 1) if what I want to do is possible with clippy, and 2) for some guidance on how to write it and publish it.

Basically I'd like concise type aliases to be presented instead verbose expanded base types. Here's an example; this an error I got while migrating a project to use the upcoming 1.0 release of scalajs-react:

[error] .../Routes.scala:56: No implicit view available from japgolly.scalajs.react.component.Js.BaseUnmounted[shipreq.webapp.client.project.app.root.LoadedRoot.Props,japgolly.scalajs.react.component.Scala.BaseMounted[[A]A,shipreq.webapp.client.project.app.root.LoadedRoot.Props,shipreq.webapp.client.project.app.root.State,rootInstance.Backend,shipreq.webapp.client.project.app.root.LoadedRoot.Props,shipreq.webapp.client.project.app.root.State],japgolly.scalajs.react.internal.Box[shipreq.webapp.client.project.app.root.LoadedRoot.Props],japgolly.scalajs.react.component.Js.BaseMounted[[A]A,japgolly.scalajs.react.internal.Box[shipreq.webapp.client.project.app.root.LoadedRoot.Props],japgolly.scalajs.react.internal.Box[shipreq.webapp.client.project.app.root.State],japgolly.scalajs.react.raw.ReactComponent with japgolly.scalajs.react.component.Scala.Vars[shipreq.webapp.client.project.app.root.LoadedRoot.Props,shipreq.webapp.client.project.app.root.State,rootInstance.Backend],japgolly.scalajs.react.internal.Box[shipreq.webapp.client.project.app.root.LoadedRoot.Props],japgolly.scalajs.react.internal.Box[shipreq.webapp.client.project.app.root.State]]] => japgolly.scalajs.react.vdom.VdomElement.

Anytime one of these underlying scalajs-react types are in a compile error, I'd love to collapse those them into a more concise form where possible. In the case above, it could instead be presented as:

.../Routes.scala:56: No implicit view available from japgolly.scalajs.react.ScalaComponent.Unmounted[shipreq.webapp.client.project.app.root.LoadedRoot.Props,shipreq.webapp.client.project.app.root.State,rootInstance.Backend] => japgolly.scalajs.react.vdom.VdomElement.

japgolly commented 7 years ago

I was hoping to avoid this case but I'd also like to add an advice to suggest that in the case of the error above, the user add:

import japgolly.scalajs.react.vdom.Implicits._
adamw commented 7 years ago

If I understand correctly, it's possible to add a suggestion to add import japgolly.scalajs.react.vdom.Implicits._. However, it's not (at least currently) possible to manipulate the original error - that is always printed as-is, with an optional advice.

As for adding the advice, you should probably extract some template from the original error, e.g.:

[error] .../Routes.scala:56: No implicit view available from japgolly.scalajs.react.component.Js.BaseUnmounted[*] => japgolly.scalajs.react.vdom.VdomElement.

(maybe it's too general) and try submitting that via the add advice form to verify if the template matches the original error.

japgolly commented 7 years ago

Thanks anyway but I'll just close this for now. Cheers