Compares two imports by their presence of a default import. An import with a default import is considered lesser (positioned higher).
Example:
// unsorted
import {a, b, c} from "alpha";
import d, {e, f} from "beta";
// sorted
import d, {e, f} from "beta";
import {a, b, c} from "alpha";
Compares two default imports whether one of them is a type. Element recognized as type imports are considered lesser (higher position).
This ignores imports without default imports.
Example:
// unsorted
import {gamma} from "Gamma";
import alpha from "Alpha";
import Beta from "Beta";
// sorted
import {gamma} from "Gamma";
import Beta from "Beta";
import alpha from "Alpha";
Compare two imports by their presence of a namespace import. An import with a namespace import is considered lesser (positioned higher).
Example:
// unsorted
import alpha from "Alpha";
import * as beta from "Beta";
// sorted
import * as beta from "Beta";
import alpha from "Alpha";
Compares two path for their depth. The deeper path is considered greater.
This ignores package names.
Note: This does not take the path names into account.
Example:
// unsorted
import a from "./longer/path";
import b from "./short-path";
// sorted
import b from "./short-path";
import a from "./longer/path";
Compares two source paths by their dir hierarchy from top to bottom. Every element of the tree is compared against the other source and alphabetically ordered.
This ignores package names.
Example:
// unsorted
import c from "./alpha-beta/alpha/c";
import b from "./alpha/gamma/b";
import a from "./alpha/beta/a";
// sorted
import a from "./alpha/beta/a";
import b from "./alpha/gamma/b";
import c from "./alpha-beta/alpha/c";
Compares two imports whether they are for side effects only or not. Imports with only side effects are considered lesser (higher position).
Example:
// unsorted
import a from "alpha";
import "beta";
import c from "charlie";
// sorted
import "beta";
import a from "alpha";
import c from "charlie";
Compares two import sources whether they are relatives or packages. A relative path is considered greater (positioned lower).
Example:
// unsorted
import b from "./Beta";
import c from "Gamma";
import a from "Alpha";
// sorted
import c from "Gamma";
import a from "Alpha";
import b from "./Beta";
Generated using TypeDoc
These are all the comparator functions for comparing two Imports with each other. They all implement ImportCompareFunction.
You can read the filenames as "sort imports (increasingly) by..."