order
UnreleasedConfiguration
Enforces a convention in module import order. Imports are sorted into groups
(builtin, external, parent, sibling, index, plus optional
internal, unknown, object, type) and each group must appear in the
configured order.
This rule is autofixable.
Rule Details
By default, imports are placed in this order:
Examples of incorrect code:
Examples of correct code:
Options
groups
Default: ["builtin", "external", "parent", "sibling", "index"]
Defines the relative order of import groups. Items can be a single string or an array (entries in the same array share a rank — they're "interchangeable" within that group).
pathGroups
Default: []
Refines the group ordering by matching specifiers against minimatch patterns.
Each entry has a pattern, a target group, and an optional position
("before" or "after").
patternOptions accepts the minimatch 3.1.5 controls for dot files,
case-insensitive and basename matching, partial prefixes, and
glob/brace/negation behavior.
pathGroupsExcludedImportTypes
Default: ["builtin", "external", "object"]
Lists import types that are NOT subject to pathGroups matching. If you want
@scope/* imports to be re-ranked by a pathGroup, remove "external" from
this list.
distinctGroup
Default: true
When true, pathGroups with a position form their own sub-group
(separated by an enforced newline when newlines-between is "always").
When false, they slot back into the parent group.
newlines-between
Default: "ignore"
Controls newlines between import groups:
"ignore"— no enforcement"always"— at least one empty line between different groups, none within"never"— no empty lines between any imports"always-and-inside-groups"— at least one empty line between groups, allowed within
newlines-between-types
Identical to newlines-between but only applies to type-only imports when
sortTypesGroup is true. Defaults to the value of newlines-between.
alphabetize
Default: { "order": "ignore", "orderImportKind": "ignore", "caseInsensitive": false }
Sorts imports alphabetically within each group.
order:"asc"|"desc"|"ignore"orderImportKind:"asc"|"desc"|"ignore"— secondary sort key used when two imports compare equal on path; sorts by kind (typevsvalue).caseInsensitive: whentrue, lowercases values before comparison.
named
Default: false
Enables ordering within named import, export, require, and CommonJS export
lists. alphabetize controls name ordering; the types setting controls the
type/value partition.
Forms accepted:
false— disabled.true— enable for named imports, exports, requires, and CJS exports.- Object form:
enabled: default for the four sub-toggles below.import: checkimport { ... } from 'mod'.export: checkexport { ... } from 'mod'.require: checkvar { ... } = require('mod').cjsExports: checkmodule.exports = { ... }and named CommonJS export assignments. As in ESLint, only declarations in the identifier's current lexical scope suppressmodule/exports; an outer-scope declaration by itself does not suppress a nested assignment.types:"mixed"|"types-first"|"types-last". Controls howimport { type T, a, b }interleaves type and value specifiers.
sortTypesGroup
Default: false
When true and "type" is in groups, type-only imports form a parallel
sub-group hierarchy mirroring the value-import group order.
warnOnUnassignedImports
Default: false
By default, side-effect imports (import './styles.css') are ignored. Set
this to true to treat them like other imports for ordering. Side-effect
imports are never autofixed because their evaluation order can be
load-bearing.
consolidateIslands
Default: "never"
When "inside-groups", multi-line imports are separated from neighboring
imports with empty lines, while consecutive single-line imports stay
together. Only meaningful with "always-and-inside-groups" newline modes.
Settings
Differences from ESLint
Compared with eslint-plugin-import 2.32.0, users may observe:
- Aliases and workspace packages may be grouped differently. Rslint can
classify an import as
internalwhere ESLint saysexternal, or vice versa. - Custom resolver settings are ignored. Imports known only through
settings["import/resolver"]may be grouped and ordered differently. - Flow
import typeofis a parse error. Rslint produces noimport/orderdiagnostic for that file. - Messages for
import type Default, { Named }can differ. Rslint callsNamedatype import; ESLint may call it an ordinary import. - Mixed
../and./paths sharing a rank have a fixed order. Ascending puts../first; descending reverses it, and repeated--fixconverges. - A move across an unassigned side-effect import is not autofixed. The ordering diagnostic remains, but rslint leaves the source unchanged.
- Named sorting skips
const { name, ...rest } = require('pkg'). Rslint leaves it unchanged instead of failing as eslint-plugin-import 2.32.0 can.