Skip to content

Add support for a `type` group

Compare
Choose a tag to compare
@willhoney7 willhoney7 released this 14 Oct 03:59

Add support for classifying type imports as an entirely separate group, if desired.

From the docs:

The type group

TypeScript has what are called type imports, e.g.,

import type { ImportantType } from './thing';

If you would like to treat these type imports as a completely separate group (instead of sorted according to the file it was imported from), add a type group to your groups list.

With the type group:

/* eslint import-helpers/order-imports: ["error", {"groups": ['sibling', 'module', 'type']}] */
import foo from './foo';
import fs from 'fs';
import path from 'path';
import type { ImportantType } from './sibling';

Without the type group:

/* eslint import-helpers/order-imports: ["error", {"groups": ['sibling', 'module']}] */
import foo from './foo';
import type { ImportantType } from './sibling';
import fs from 'fs';
import path from 'path';