Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Releases: liancheng/scalafix-organize-imports

OrganizeImports v0.5.0

01 Feb 10:18
Compare
Choose a tag to compare

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 setting groupedImports to Explode, 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 the coalesceToWildcardImportThreshold 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 to Manual, you may configure blank lines by adding "---" to the groups option. For example, now you can have the following configuration to group java, javax, and scala imports together without blank lines:

    OrganizeImports {
      blankLines = Manual
      groups = [
        "*"
        "---"
        "java."
        "javax."
        "scala."
      ]
    }
    

    By default, blankLines is set to Auto, 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

  • Renames and wildcard should not be separated (#151)
  • Fix importer order when sorting by ASCII (#149)

Acknowledgement

Many thanks to the following users and contributors for their valuable feedback and contributions!

OrganizeImports v0.5.0-alpha.1

13 Jan 03:08
Compare
Choose a tag to compare
Pre-release

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 to Manual, you may configure blank lines by adding "---" to the groups option. For example, now you can have the following configuration to group java, javax, and scala imports together without blank lines:

    OrganizeImports {
      blankLines = Manual
      groups = [
        "*"
        "---"
        "re:(javax?|scala)\\."
      ]
    }
    

    By default, blankLines is set to Auto, 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 to Merge
    • 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

12 Jan 03:16
67ab8d9
Compare
Choose a tag to compare

This release includes the following bug fix as well as several regular dependency updates:

  • Preserve the original source-level formatting when possible after merging imports (#128, fixes #127)

OrganizeImports v0.4.3

20 Oct 07:19
ba6bd39
Compare
Choose a tag to compare

Feature:

  • Add the AggressiveMerge option for the groupedImports configuration (#119, closing #105)

OrganizeImports v0.4.2

28 Sep 18:09
cdc0165
Compare
Choose a tag to compare

This release adds support for cross-compiling Scala 2.11 (by @gabro)

  • Cross-compile rule for 2.11 (#113)
  • Fix removeUnused on 2.11 (#114)

OrganizeImports v0.4.1

22 Sep 06:30
Compare
Choose a tag to compare

Bug fixes:

  • characters ` are missing after reorganize import (#101)

Other changes:

  • Add in example for how to use with Mill. (#102 by @ckipp01)

OrganizeImports v0.4.0

18 Jul 20:36
Compare
Choose a tag to compare

Improvements:

  • Remove unneeded curly-braces in imports with only a single name imported (#97, #96)
  • Remove duplicate importees (#82, #81)
  • Allow -Xlint in OrganizeImports.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

07 May 10:32
Compare
Choose a tag to compare

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)