{"id":13482824,"url":"https://github.com/simonhaenisch/prettier-plugin-organize-imports","last_synced_at":"2025-05-14T09:09:09.506Z","repository":{"id":37097941,"uuid":"237527660","full_name":"simonhaenisch/prettier-plugin-organize-imports","owner":"simonhaenisch","description":"Make Prettier organize your imports using the TypeScript language service API.","archived":false,"fork":false,"pushed_at":"2024-09-20T22:55:56.000Z","size":96,"stargazers_count":1062,"open_issues_count":5,"forks_count":32,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-29T15:20:44.351Z","etag":null,"topics":["javascript","jsx","prettier","prettier-plugin","sort-imports","tsx","typescript","vue"],"latest_commit_sha":null,"homepage":"https://npmjs.com/prettier-plugin-organize-imports","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonhaenisch.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"simonhaenisch"}},"created_at":"2020-01-31T22:33:39.000Z","updated_at":"2024-10-28T19:28:02.000Z","dependencies_parsed_at":"2024-05-30T01:27:42.438Z","dependency_job_id":"e46e2a6e-21df-4cdc-91f9-b7ade740df4f","html_url":"https://github.com/simonhaenisch/prettier-plugin-organize-imports","commit_stats":{"total_commits":152,"total_committers":10,"mean_commits":15.2,"dds":0.07236842105263153,"last_synced_commit":"e79ed64e5ecd05bdd65140b814b37c9a1a360767"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonhaenisch%2Fprettier-plugin-organize-imports","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonhaenisch%2Fprettier-plugin-organize-imports/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonhaenisch%2Fprettier-plugin-organize-imports/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonhaenisch%2Fprettier-plugin-organize-imports/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonhaenisch","download_url":"https://codeload.github.com/simonhaenisch/prettier-plugin-organize-imports/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253700544,"owners_count":21949693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","jsx","prettier","prettier-plugin","sort-imports","tsx","typescript","vue"],"created_at":"2024-07-31T17:01:05.868Z","updated_at":"2025-05-14T09:09:04.486Z","avatar_url":"https://github.com/simonhaenisch.png","language":"JavaScript","funding_links":["https://github.com/sponsors/simonhaenisch"],"categories":["JavaScript"],"sub_categories":[],"readme":"[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/simonhaenisch/prettier-plugin-organize-imports/test.yml?label=CI)](https://github.com/simonhaenisch/prettier-plugin-organize-imports/actions?query=branch%3Amaster)\n\n# Prettier Plugin: Organize Imports\n\n\u003e Make sure that your import statements stay consistent no matter who writes them and what their preferences are.\n\nA plugin that makes Prettier organize your imports (i. e. sorts, combines and removes unused ones) using the `organizeImports` feature of the TypeScript language service API. This is the same as using the \"Organize Imports\" action in VS Code.\n\n**Features**\n\n- 👌 Dependency-free (just peer-dependencies you probably already have).\n- 💪 Supports `.js`, `.jsx`, `.ts`, `.tsx` and `.vue` files.\n- 🚀 Zero config.\n- 🤓 No more weird diffs or annoying merge conflicts in PRs caused by import statements.\n- 🤯 If your editor supports auto-imports, you'll stop thinking about your imports so much that you won't even care about their order anymore.\n\n**Caveat**\n\nThis plugin inherits, extends, and then overrides the built-in Prettier parsers for `babel`, `babel-ts`, `typescript` and `vue`. This means that it is incompatible with other plugins that do the same; only the last loaded plugin that exports one of those parsers will function.\n\n## Installation\n\n```sh\nnpm install --save-dev prettier-plugin-organize-imports\n```\n\n_Note that `prettier` and `typescript` are peer dependencies, so make sure you have those installed in your project._\n\n## Usage\n\n### Prettier 3\n\nAutomatic plugin discovery [has been removed](https://prettier.io/blog/2023/07/05/3.0.0.html#plugin-search-feature-has-been-removed-14759httpsgithubcomprettierprettierpull14759-by-fiskerhttpsgithubcomfisker). Thus you need to configure Prettier to use the plugin according to the [Plugins docs](https://prettier.io/docs/en/plugins.html), for example by adding it to the `plugins` config option:\n\n```json\n{\n  \"plugins\": [\"prettier-plugin-organize-imports\"]\n}\n```\n\n### Prettier 2\n\nThe plugin will be loaded by Prettier automatically. No configuration needed.\n\nNote that automatic plugin discovery is not supported with some package managers, e. g. Yarn PnP (see https://github.com/prettier/prettier/issues/8474). In that case follow the instructions for Prettier 3 above.\n\n## Configuration\n\n### Skip Files\n\nFiles containing the substring `// organize-imports-ignore` or `// tslint:disable:ordered-imports` are skipped.\n\n### Skip Destructive Code Actions\n\nIf you don't want destructive code actions (like removing unused imports), you can enable the option `organizeImportsSkipDestructiveCodeActions` via your Prettier config.\n\n```json\n{\n  \"organizeImportsSkipDestructiveCodeActions\": true\n}\n```\n\n## Compatibility\n\n### ESLint\n\nFor compatibility with [ESLint](https://eslint.org/) or other linters, see [\"Integrating with Linters\"](https://prettier.io/docs/en/integrating-with-linters.html) in the Prettier docs. You should have any import order rules/plugins disabled.\n\n### React\n\nDepending on your configuration, if you need the `React` import to stay even if it's \"unused\" (i.e. only needed for the JSX factory), make sure to have the `jsx` option set to `react` in your `tsconfig.json`. For more details [click here](https://www.typescriptlang.org/docs/handbook/jsx.html#basic-usage).\n\n### Vue.js\n\nMake sure that you have the optional peer dependency `vue-tsc` installed.\n\n```\nnpm install --save-dev vue-tsc\n```\n\nIf you're using Vue.js with Pug templates, you'll also need to install `@vue/language-plugin-pug` as a dev dependency, and configure it in `vueCompilerOptions` (see [usage](https://www.npmjs.com/package/@vue/language-plugin-pug)).\n\n## Debug Logs\n\nIf something doesn't work, you can try to prefix your `prettier` command with `DEBUG=true` which will enable this plugin to print some logs.\n\n## Rationale/Disclaimer\n\nThis plugin acts outside of [Prettier's scope](https://prettier.io/docs/en/rationale#what-prettier-is-_not_-concerned-about) because _\"Prettier only prints code. It does not transform it.\"_, and technically sorting is a code transformation because it changes the AST (this plugin even removes code, i. e. unused imports). In my opinion however, the import statements are not _really_ part of the code, they are merely directives that instruct the module system where to find the code (only true as long as your imports are side-effects free regarding the global scope, i. e. import order doesn't matter), comparable with `using` directives in C# or `#include` preprocessing directives in C. Therefore the practical benefits outweigh sticking with the philosophy in this case.\n\n## Changelog\n\nSee [changelog.md](/changelog.md).\n\n## License\n\n[MIT](/license).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonhaenisch%2Fprettier-plugin-organize-imports","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonhaenisch%2Fprettier-plugin-organize-imports","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonhaenisch%2Fprettier-plugin-organize-imports/lists"}