Require Import Order
Require 6-group import ordering: regular Node built-ins, regular third-party, regular local, then type Node built-ins, type third-party, type local — each group separated by a blank line and sorted alphabetically within.
Summary
The require-import-order rule enforces a strict 6-group ordering:
- Regular Node built-ins
- Regular third-party
- Regular local
- Type Node built-ins
- Type third-party
- Type local
Groups must be separated by blank lines, and imports within the same group must be in alphabetical order. Import specifiers within a single import statement must also be alphabetical.
Why Use This Rule?
- Consistent import ordering makes it easy to locate a specific import at a glance.
- Blank lines between groups visually separate concerns — platform, dependencies, and project code.
- Alphabetical ordering within groups eliminates merge conflicts from arbitrary insertion order.
Examples
Configuration
Options
warning
ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.
| Option | Type | Default | Description |
|---|---|---|---|
ignoreFiles | string[] | [] | File patterns to skip. |
Autofix
Autofix is not available for this rule. Flagged code must be updated manually.
Troubleshooting
- Warning fires on a type import before a local import — Type imports always come after all regular imports. Move
import typestatements to the end of the import block. - Warning says specifiers are not alphabetical — Named specifiers inside
{ A, B, C }must be sorted alphabetically. Reorder them to match. - Bare Node built-in without
node:prefix is flagged — The rule recognizes bare built-in module names (e.g.,fs,path) and treats them the same asnode:fs. If it is flagged, the ordering issue is with the group, not the prefix.