@arnaud-barre/prettier-plugin-sort-imports

0.1.3 • Public • Published

@arnaud-barre/prettier-plugin-sort-imports npm

A small low-overhead TS-only Prettier plugin to sort imports. Inspired by IanVS/prettier-plugin-import-sort.

This package is using a monkey-patch of the estree pinter preprocess to avoid a double code -> AST -> code pass. This is obviously not stable, but allows to get everything I need for 200 lines of code and without any dependency.

The plugin is published as an ESM module, so it requires Prettier 3.

This plugin sorts imports into 4 groups (bun:, node:, <packages>, .<relative>), with a natural sorting inside each group. Comments follow the imports they are attached too. There is no special handling for TS paths.

Features

  • Don't reorder imports across side effect imports
  • Enforce node: prefix
  • Merge imports statement from the same module
  • Use import type for type only imports

Readme

Keywords

none

Package Sidebar

Install

npm i @arnaud-barre/prettier-plugin-sort-imports

Weekly Downloads

26

Version

0.1.3

License

MIT

Unpacked Size

8.18 kB

Total Files

4

Last publish

Collaborators

  • arnaud-barre