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

OrganizeImports v0.5.0

Latest
Compare
Choose a tag to compare
@liancheng liancheng released this 01 Feb 10:18
· 91 commits to master since this release

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!