Releases: liancheng/scalafix-organize-imports
OrganizeImports v0.5.0
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!
OrganizeImports v0.5.0-alpha.1
This pre-release contains a new feature and a couple of backward-incompatible changes. It aims to make existing IntelliJ IDEA users' life easier when adopting OrganizeImports
.
-
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 = [ "*" "---" "re:(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. -
Default value changes (#143 and #146 by @sideeffffect)
groupedImports
now defaults toMerge
groups
now defaults to["*", "re:(javax?|scala)\\."]
Both values follow the default configuration of the IntelliJ Scala import optimizer (as in version 2020.3).
Many thanks to all the feedback and contributions!
OrganizeImports v0.4.4
OrganizeImports v0.4.3
OrganizeImports v0.4.2
OrganizeImports v0.4.1
OrganizeImports v0.4.0
Improvements:
- Remove unneeded curly-braces in imports with only a single name imported (#97, #96)
- Remove duplicate importees (#82, #81)
- Allow
-Xlint
inOrganizeImports.removeUnused
(#80) - Cross-build to 2.13 (#69)
- Skip package object parent symbols when expanding relative imports (#58, #55)
- Do not rewrite already organized imports formatted by Scalafmt (#46, #44, #43)
Bug fixes:
- Imports may be sorted in wrong order when some of them are not rewritten (#85, #84)
- Invalid code generated due to inheritance (#78, #65)
- Infinite loop caused by missing symbol information (#90, #75, #64)
- Do not remove
_root_
while expanding relative imports (#63, #62) - Handling edge cases caused by explicitly imported implicit names (#30, #61, #59, #40)
- Remove unused local imports (#49, #46)
- Fix test Codecov test coverage report (#70, #54)
Huge thanks to the following contributors for this release!
Please refer to the v0.4.0 milestone for a complete list of features and fixes.
OrganizeImports v0.3.0
New features:
- Supports IntelliJ IDEA style import sort order (#23, #37)
- Allows coalescing to a wildcard import when the number of grouped import selectors exceeds a configurable threshold (#29)
Bug fixes:
- Wildcard should always appear at last in a grouped import (#21)
- Fix various corner cases while merging imports with the same prefix (#24)
- Symbols with EmptyPackage as their owner are also fully-qualified (#26)
- Explicitly imported names should not be removed while exploding or merging imports (#28)
- Fix a corner case about quoted identifiers containing curly braces (#32)
- Implements the SymbolsFirst import sorting order properly (#37)
- Always move explicitly imported implicits into the trailing order preserving import group (#38)