Skip to contentSlop Block

require-sorted-named-imports

Hint

Sort the names in an import list alphabetically by local name, ignoring case. The check compares first letters only.

import { beta, alpha } from "alpha";Sort the names in this import list alphabetically
import { gamma, Alpha } from "alpha";Sort the names in this import list alphabetically
import { Tooltip as Root, Anchor } from "ark";Sort the names in this import list alphabetically
import { beta, type Alpha } from "alpha";Sort the names in this import list alphabetically
import beta, { gamma, alpha } from "alpha";Sort the names in this import list alphabetically
import {	gamma,	beta,Sort the names in this import list alphabetically	alpha,} from "alpha";
// ast-grep-ignore: require-sorted-named-imports-typescript

How to fix

Sort the names between the braces alphabetically, ignoring case, by the name the file uses: the alias in Tooltip as Root, not the exported name. A type modifier does not change the position.

ast-grep cannot compare two names, so the check only reports a name whose first letter comes before the first letter of the name above it. Two names that share a first letter are never reported; order them by hand.