javascript-eslint-import-order
Deterministically rewrites the top static ESM import block to follow eslint-plugin-import import/order conventions: group imports, insert exactly one blank line between non-empty groups, and alphabetize declarations within each group.
What It Changes
- Reorders the contiguous top-level
importblock, while preserving leading directives and file-level pragmas/comments above it. - Uses these groups, in order:
builtin,external,internal,parent,sibling,index,type. - Preserves side-effect-only imports (
import "x";) in their original positions relative to other imports by default. - Keeps comments attached to their import when they move.
- Leaves specifier lists unchanged.
Safe Defaults And Skips
- Files with zero or one top-level static import are left unchanged.
- CommonJS
require(...)statements are ignored. - Files with ambiguous comments between the top import block and code are skipped unless
force=true. - TypeScript
import = require()forms in the top import block are treated as unsupported and skipped.
Supported Files
- JavaScript:
.js,.jsx,.mjs,.cjs - TypeScript:
.ts,.tsx
Parameters
internal_alias_prefixes: comma-separated prefixes treated asinternalimports. Default:@/unsafe_sort_side_effect_imports: whentrue, side-effect-only imports are sorted instead of preserved. Default:falsetype_grouping:groupto emit type-only imports as a finaltypegroup, orinlineto keep them in their source group. Default:grouptype_position: whentype_grouping=inline, place type-only importsfirstorlastwithin equal-source ordering. Default:lastcase_sensitive: whentrue, preserve case-sensitive alphabetical ordering. Default:falseforce: whentrue, allows rewriting files with ambiguous trailing comments after the top import block. Default:false
Example
Before:
ts
After:
ts
Installation
bash
Or run the local package:
bash
Development
bash
License
MIT