Options
All
  • Public
  • Public/Protected
  • All
Menu

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..."

Index

Functions

  • 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";
    see

    ImportElement#isDefault

    Parameters

    Returns number

  • 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";
    see

    ImportElement#isType

    Parameters

    Returns number

  • 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";
    see

    Import#isNamespace

    Parameters

    Returns number

  • 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";

    Parameters

    Returns number

  • 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";

    Parameters

    Returns number

  • 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";

    Parameters

    Returns number

  • Compares two imports based on their source name alphabetically.

    This ignores relative sources.

    Example:

    // unsorted
    import a from "beta";
    import b from "alpha";

    // sorted
    import b from "alpha";
    import a from "beta";

    Parameters

    Returns number

  • 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";
    see

    ImportSource#isPackage

    see

    ImportSource#isRelative

    Parameters

    Returns number

Generated using TypeDoc