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
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
Motivation: The com.nequissimus:sort-imports:0.6.1 scalafix plugin is outdated and no longer maintained. Scalafix's built-in OrganizeImports rule provides equivalent functionality with better integration and active maintenance. Modification: - Replace SortImports rule with OrganizeImports in .scalafix.conf - Remove sort-imports dependency from ScalaFixExtraRulesPlugin - Update sortImports command alias to use OrganizeImports - Add -Wunused:imports to scalac options (required by removeUnused) - Configure import groups to match Pekko's existing style: java/scala/com.sun first, then org.apache.pekko and pekko.* imports, followed by third-party libraries - Remove SortImports from .scalafmt.conf rewrite rules - Add JDK21-only test files to ignored-files (no SemanticDB available) - Set RemoveUnused.imports = false to avoid conflict with OrganizeImports Result: Import formatting now uses scalafix's built-in OrganizeImports rule with removeUnused = true, which also cleans up accumulated unused imports. The sort-imports external dependency is no longer needed. Tests: sbt sortImports (scalafixEnable + scalafixAll OrganizeImports + scalafmtAll) References: None - build tooling improvement
19368ae to
8131b4b
Compare
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