This release features better compatibility with IntelliJ Scala plugin 2020.3 and contains breaking changes.
Changes
Breaking changes
- The default value of the
groups
option is changed to["*", "re:(javax?|scala)\\."]
to align with IntelliJ Scala plugin 2020.3
Features
-
Add preset styles, including one for IntelliJ IDEA 2020.3 (#154)
Two preset styles are added:
-
DEFAULT
An opinionated style recommended for new projects. The
OrganizeImports
rule tries its best to ensure correctness in all cases when possible. This default style aligns with this principal. In addition, by settinggroupedImports
toExplode
, this style is also more friendly to version control and less likely to create annoying merge conflicts caused by trivial import changes.OrganizeImports { blankLines = Auto coalesceToWildcardImportThreshold = null expandRelative = false groupExplicitlyImportedImplicitsSeparately = false groupedImports = Explode groups = [ "*" "re:(javax?|scala)\\." ] importSelectorsOrder = Ascii importsOrder = Ascii preset = DEFAULT removeUnused = true }
-
INTELLIJ_2020_3
A style that is compatible with the default configuration of IntelliJ Scala plugin 2020.3. It is mostly useful for adding
OrganizeImports
to existing projects developed using the IntelliJ Scala plugin. However, this configuration may introduce subtle correctness issues (so does the default configuration of the IntelliJ Scala plugin). Please see thecoalesceToWildcardImportThreshold
option for more details.OrganizeImports { blankLines = Auto coalesceToWildcardImportThreshold = 5 expandRelative = false groupExplicitlyImportedImplicitsSeparately = false groupedImports = Merge groups = [ "*" "re:(javax?|scala)\\." ] importSelectorsOrder = Ascii importsOrder = Ascii preset = INTELLIJ_2020_3 removeUnused = true }
-
-
Allow customizing blank lines between organized import groups (#142)
The IntelliJ Scala import optimizer not only allows you group imports but also allows you to decide whether a blank line should be inserted between two adjacent import groups. This feature introduces a new configuration option
blankLines
. When it's set toManual
, you may configure blank lines by adding"---"
to thegroups
option. For example, now you can have the following configuration to groupjava
,javax
, andscala
imports together without blank lines:OrganizeImports { blankLines = Manual groups = [ "*" "---" "java." "javax." "scala." ] }
By default,
blankLines
is set toAuto
, which preserves the original behavior, i.e., a blank line is automatically inserted between adjacent import groups.This makes migrating IntelliJ Scala import optimizer configurations of existing projects to
OrganizeImports
easier.
Bug fixes
Acknowledgement
Many thanks to the following users and contributors for their valuable feedback and contributions!