# prettier-plugin-astro-organize-imports

> A Prettier plugin for formatting imports in Astro files

Latest version **0.4.14** (published 2026-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install prettier-plugin-astro-organize-imports
pnpm add prettier-plugin-astro-organize-imports
yarn add prettier-plugin-astro-organize-imports
bun add prettier-plugin-astro-organize-imports
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.4.14 |
| Published | 2026-10-02 |
| First published | 2023-06-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 46 |
| Author | neoki |
| Maintainers | oki07 |
| Keywords | plugin, formatter, prettier, astro, sort-imports |

## Links

- npm: https://www.npmjs.com/package/prettier-plugin-astro-organize-imports
- Repository: https://github.com/oki07/prettier-plugin-astro-organize-imports
- Homepage: https://github.com/oki07/prettier-plugin-astro-organize-imports#readme
- Issues: https://github.com/oki07/prettier-plugin-astro-organize-imports/issues
- npm.io page: https://npm.io/package/prettier-plugin-astro-organize-imports

## Dependencies (2)

- [typescript](https://npm.io/package/typescript.md) ^6.0.2
- [@astrojs/compiler](https://npm.io/package/@astrojs/compiler.md) ^3.0.1

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 0.4.14 (latest) — 2026-10-02
- 0.4.13 — 2026-08-23
- 0.4.12 — 2026-04-07
- 0.4.11 — 2024-11-04
- 0.4.10 — 2024-09-26
- 0.4.9 — 2024-06-25
- 0.4.8 — 2024-05-13
- 0.4.7 — 2024-05-04
- 0.4.6 — 2024-05-04
- 0.4.5 — 2024-04-11
- 0.4.4 — 2024-04-10
- 0.4.3 — 2024-02-26
- 0.4.2 — 2024-02-25
- 0.4.1 — 2024-01-26
- 0.4.0 — 2024-01-24
- … 10 more at https://npm.io/package/prettier-plugin-astro-organize-imports/versions

## README

# [Prettier](https://prettier.io/) Plugin: Organize Imports for [Astro](https://astro.build/)

[![license](https://img.shields.io/github/license/neoki07/prettier-plugin-astro-organize-imports)](https://github.com/neoki07/prettier-plugin-astro-organize-imports/blob/main/LICENSE)
[![npm](https://img.shields.io/npm/v/prettier-plugin-astro-organize-imports.svg)](https://www.npmjs.com/package/prettier-plugin-astro-organize-imports)
[![npm downloads](https://img.shields.io/npm/dm/prettier-plugin-astro-organize-imports)](https://www.npmjs.com/package/prettier-plugin-astro-organize-imports)
[![ci](https://github.com/neoki07/prettier-plugin-astro-organize-imports/actions/workflows/ci.yml/badge.svg)](https://github.com/neoki07/prettier-plugin-astro-organize-imports/actions/workflows/ci.yml)

A plugin that makes Prettier organize your imports (i. e. sorts, combines and removes unused ones) in Astro files using the `organizeImports` feature of the TypeScript language service API.

<p align="center">
  <img src="assets/images/demo.gif" alt="Demo" />
</p>

## Installation

```shell
npm install -D prettier prettier-plugin-astro-organize-imports
```

### Recommended configuration

<!-- prettier-ignore -->
```json5
// .prettierrc
{
  "plugins": ["prettier-plugin-astro-organize-imports"],
  "overrides": [
    {
      "files": "*.astro",
      "options": {
        "parser": "astro"
      }
    }
  ]
}
```

<!-- prettier-ignore-end -->

## Usage

After following the steps in the 'Installation' section, the plugin will function when you run the Prettier formatting command.

Files containing the substring `// organize-imports-ignore` or `// tslint:disable:ordered-imports` will be skipped and won't be processed by this plugin.

The plugin provides an option named `astroOrganizeImportsMode` that lets you choose the mode of formatting. The available options are:

- `All`: This is the default option. It removes unused imports, coalesces imports from the same module, and sorts imports.
- `SortAndCombine`: This option coalesces imports from the same module and sorts imports.
- `RemoveUnused`: This option removes the unused imports.

You can specify the mode in your Prettier configuration file as follows:

<!-- prettier-ignore -->
```json5
// .prettierrc
{
  // ..
  "astroOrganizeImportsMode": "All" // or "SortAndCombine" or "RemoveUnused"
}
```

<!-- prettier-ignore-end -->

Remember to replace "All" with "SortAndCombine" or "RemoveUnused" depending on your preferences.

## Compatibility with other Prettier plugins

This plugin uses Prettier APIs that can only be used by one plugin at a time, making it incompatible with other Prettier plugins implemented the same way. To solve this we've added explicit per-plugin workarounds that enable compatibility with the following Prettier plugins:

- `prettier-plugin-astro`
- `prettier-plugin-tailwindcss`

One limitation with this approach is that `prettier-plugin-astro-organize-imports` must be loaded last. You can do this by listing each of your Prettier plugins in the `plugins` array:

<!-- prettier-ignore -->
```json5
// .prettierrc
{
  // ..
  "plugins": [
    "prettier-plugin-astro",
    "prettier-plugin-tailwindcss",
    "prettier-plugin-astro-organize-imports" // MUST come last
  ],
  "overrides": [
    {
      "files": "*.astro",
      "options": {
        "parser": "astro"
      }
    }
  ]
}
```

<!-- prettier-ignore-end -->

## Related Prettier plugins

This plugin is heavily inspired by following plugins:

- [prettier-plugin-organize-imports](https://github.com/simonhaenisch/prettier-plugin-organize-imports)

And, for implementation reference, the following plugins:

- [prettier-plugin-astro](https://github.com/withastro/prettier-plugin-astro)
- [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)

---
_Source: https://npm.io/package/prettier-plugin-astro-organize-imports · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
