refactor: replace sort-imports plugin with scalafix OrganizeImports#3342
Draft
He-Pin wants to merge 1 commit into
Draft
refactor: replace sort-imports plugin with scalafix OrganizeImports#3342He-Pin wants to merge 1 commit into
He-Pin wants to merge 1 commit into
Conversation
Motivation: The com.nequissimus:sort-imports:0.6.1 plugin has not been updated since December 2021 and is effectively unmaintained. Scalafix's built-in OrganizeImports rule (available since 0.11.0) is more powerful, actively maintained, and requires no external dependency. Modification: - Replace SortImports rule with OrganizeImports in .scalafix.conf, configured with 10 import groups matching Pekko's existing style - Remove SortImports from .scalafmt.conf rewrite.rules to avoid conflict - Remove com.nequissimus:sort-imports:0.6.1 dependency - Update sortImports command alias to use OrganizeImports - Add -Wunused:imports compiler option for Scala 2.13 and Scala 3 - Disable RemoveUnused.imports (conflicts with OrganizeImports) and enable OrganizeImports.removeUnused instead - Add JDK21-only test files to ignored-files list - Apply full project import reformatting (main + test sources) Result: Import sorting uses scalafix's built-in OrganizeImports rule with no external dependency. The sortImports command continues to work as before, now also removing unused imports automatically. Tests: - sbt sortImports completed successfully with Java 21 References: None - build tooling improvement
ba97a4b to
19368ae
Compare
He-Pin
commented
Jul 13, 2026
| @@ -48,7 +48,7 @@ addCommandAlias( | |||
| name = "fixall", | |||
| value = ";scalafixEnable; scalafixAll; scalafmtAll; test:compile; multi-jvm:compile; reload") | |||
|
|
|||
| addCommandAlias(name = "sortImports", value = ";scalafixEnable; scalafixAll SortImports; scalafmtAll") | |||
| addCommandAlias(name = "sortImports", value = ";scalafixEnable; scalafixAll OrganizeImports; scalafmtAll") | |||
|
|
|||
pjfanning
reviewed
Jul 13, 2026
| import scala.util.control.NonFatal | ||
|
|
||
| import org.apache.pekko | ||
|
|
Member
There was a problem hiding this comment.
this is a change that I prefer that we fix - let's keep no gap between the org.apache.pekko import and the pekko imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The
com.nequissimus:sort-imports:0.6.1plugin has not been updated since December 2021 and is effectively unmaintained. Scalafix's built-inOrganizeImportsrule (available since 0.11.0, project uses 0.14.7) is more powerful, actively maintained, and requires no external dependency.Modification
SortImportsrule withOrganizeImportsin.scalafix.conf, configured with 10 import groups matching Pekko's existing style (java/javax, scala, third-party, com.sun, pekko/akka, reactivestreams, netty, scalatest, slf4j, typesafe)SortImportsfrom.scalafmt.confrewrite.rulesto avoid conflict with scalafixcom.nequissimus:sort-imports:0.6.1dependency fromScalaFixExtraRulesPluginsortImportscommand alias inbuild.sbt,ScalaFixForJdk21Plugin, andScalafixForMultiNodePluginto useOrganizeImports-Wunused:importscompiler option for Scala 2.13 and Scala 3 to supportOrganizeImports.removeUnusedRemoveUnused.imports(conflicts withOrganizeImports) and enableOrganizeImports.removeUnused = trueinsteadResult
Import sorting now uses scalafix's built-in
OrganizeImportsrule with no external dependency. Thesbt sortImportscommand continues to work as before, now also automatically removing unused imports. Import grouping matches Pekko's existing style with 10 configured groups.Tests
sbt "Test / compile"passed with Java 21References
None - build tooling improvement