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

Add Scalafix Organize Imports #20

Merged
merged 6 commits into from
Aug 23, 2023
Merged

Add Scalafix Organize Imports #20

merged 6 commits into from
Aug 23, 2023

Conversation

valencik
Copy link
Member

@valencik valencik commented Jun 4, 2022

Resolves #19

@valencik valencik self-assigned this Jun 4, 2022
@valencik
Copy link
Member Author

valencik commented Jun 4, 2022

Hmmm, after adding a basic .scalafix.conf, things don't "just work"

With no changes to build.sbt tlCiScalafixCheck returns:

[info] coreJVM / tlCiScalafixCheck
[info]  false
[info] coreJS / tlCiScalafixCheck
[info]  false
[info] tlCiScalafixCheck
[info]  false

Which is expected. If we add the following

ThisBuild / tlCiScalafixCheck := true

then tlCiScalafixCheck returns true, as expected

but prePR doesn't seem to run scalafix?

prePR output
sbt:root> prePR
[info] welcome to sbt 1.6.2 (N/A Java 17.0.1)
[info] loading settings for project global-plugins from sbt-updates.sbt ...
[info] loading global plugins from /home/andrew/.sbt/1.0/plugins
[info] loading settings for project junk-build from plugins.sbt ...
[info] loading project definition from /home/andrew/src/junk/project
[info] loading settings for project root from build.sbt ...
[info] set current project to root (in build file:/home/andrew/src/junk/)
[info] set current project to root (in build file:/home/andrew/src/junk/)
[success] Total time: 0 s, completed Jun 4, 2022, 8:53:26 AM
[success] Total time: 0 s, completed Jun 4, 2022, 8:53:26 AM
[success] Total time: 0 s, completed Jun 4, 2022, 8:53:26 AM
[info] scalafmt: Formatting 1 Scala sources (/home/andrew/src/junk/core/.js)...
[info] scalafmt: Formatting 1 Scala sources (/home/andrew/src/junk/core/.js)...
[info] scalafmt: Formatting 1 Scala sources (/home/andrew/src/junk/core/.jvm)...
[info] scalafmt: Formatting 1 Scala sources (/home/andrew/src/junk/core/.jvm)...
[success] Total time: 1 s, completed Jun 4, 2022, 8:53:26 AM
[info] scalafmt: Formatting 2 Scala sources (/home/andrew/src/junk)...
[success] Total time: 0 s, completed Jun 4, 2022, 8:53:27 AM
[info] Defining ThisBuild / tlFatalWarnings
[info] The new value will be used by coreJS / javacOptions, coreJS / scalacOptions and 11 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] set current project to root (in build file:/home/andrew/src/junk/)
[info] compiling 1 Scala source to /home/andrew/src/junk/core/.js/target/scala-2.13/classes ...
[info] compiling 1 Scala source to /home/andrew/src/junk/core/.jvm/target/scala-2.13/classes ...
[info] compiling 1 Scala source to /home/andrew/src/junk/core/.js/target/scala-2.13/test-classes ...
[info] compiling 1 Scala source to /home/andrew/src/junk/core/.jvm/target/scala-2.13/test-classes ...
[success] Total time: 3 s, completed Jun 4, 2022, 8:53:31 AM
[info] welcome to sbt 1.6.2 (N/A Java 17.0.1)
[info] loading settings for project global-plugins from sbt-updates.sbt ...
[info] loading global plugins from /home/andrew/.sbt/1.0/plugins
[info] loading settings for project junk-build from plugins.sbt ...
[info] loading project definition from /home/andrew/src/junk/project
[info] loading settings for project root from build.sbt ...
[warn] Discarding 1 session setting.  Use 'session save' to persist session settings.
[info] set current project to root (in build file:/home/andrew/src/junk/)

Perhaps more concerning, there's no scalafix commands in scope within sbt in a generated project.

sbt:root> scalafix
[error] Not a valid command: scalafix

@armanbilge
Copy link
Member

Perhaps more concerning, there's no scalafix commands in scope within sbt in a generated project.

That's because we need to add another dependency.

addSbtPlugin("org.typelevel" % "sbt-typelevel-scalafix" % "0.4.10")

Then you can remove ThisBuild / tlCiScalafixCheck := true, since that plugin enables it automatically.

We can't ship it by default until 0.5.0, because it could be a breaking change for some builds. That's also why it doesn't appear in the prePR command currently ...

So it would be totally valid to put this off until it's more baked in.

@armanbilge
Copy link
Member

@armanbilge armanbilge marked this pull request as ready for review August 23, 2023 02:45
@armanbilge armanbilge merged commit 232fc21 into main Aug 23, 2023
11 checks passed
@armanbilge armanbilge deleted the org-imports branch August 23, 2023 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scalafix integration
2 participants