Skip to content

[import-order] order within import type #2172

@alvis

Description

@alvis

Now, import type can be a separate group.
I also find the ability to alphabetize very useful.

However, I find it very annoying that they don't work well together.
The problem is that the order of import type statement doesn't follow the order we define for other module types.
Let's say we have the following options

"import/order": [
  "warn",
  {
    "groups": [
      "builtin",
      "external",
      "type"
    ],
    "newlines-between": "always-and-inside-groups",
    "alphabetize": { "order": "asc", "caseInsensitive": true }
  }
],

e.g. I'd like to have the following order

// buildin modules before external modules

// for ordinary import it's ok, builtin first, then external
import { createServer } from 'http'

import { graphql } from 'gatsby';

// but for `import type` it warns that the gatsby import should be put in front of the http one
// the order is right here since http is a buildin and gatsby is an external
import type { RequestOptions } from 'http'

import type { PageProps } from 'gatsby';

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions