Sort Imports Save

A simplistic Scalafix rule that sorts imports

Project README

SortImports

GitHub Workflow Status GitHub commits since latest release GitHub last commit GitHub contributors

GitHub tag (latest SemVer) GitHub Release Date

Scala Steward badge License

Description

SortImports is a simplistic Scalafix rule.

It will organize imports into prefix-blocks and order imports inside those blocks alphabetically.

For example, these imports

import scala.util._
import scala.collection._
import java.util.Map
import org.xml._
import com.sun._

will be organized as follows

import java.util.Map

import scala.collection._
import scala.util._

import org.xml._

import com.sun._

if the blocks from the below Configuration example are used.

Important sort-imports does not (currently) take into account shadowing. It is a faily dumb sorter of imports. If your code is using shadowing, it may end up no longer compiling! If you run into this issue, consider using liancheng/scalafix-organize-imports, which implements a semantic rule.

Usage

Latest version: GitHub tag (latest SemVer)

ThisBuild / scalafixDependencies += "com.nequissimus" %% "sort-imports" % "<VERSION>"

Configuration

rule = SortImports
SortImports.blocks = [
  "re:javax?\\.", // a re: prefix denotes a regex, this will group java. and javax. packages together
  "scala.",
  "*",
  "com.sun."
]
Open Source Agenda is not affiliated with "Sort Imports" Project. README Source: NeQuissimus/sort-imports
Stars
58
Open Issues
13
Last Commit
1 month ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating