{"library":"prettier-plugin-organize-imports","title":"Prettier Plugin: Organize Imports","description":"This Prettier plugin automates the organization of import statements within your JavaScript, TypeScript, JSX, TSX, and Vue files. It leverages the TypeScript language service API's `organizeImports` feature, which is the same logic used by VS Code's 'Organize Imports' action. The plugin sorts, combines, and removes unused imports, ensuring consistent import structures across your codebase and reducing merge conflicts related to import ordering. The current stable version is 4.3.0, with minor releases occurring periodically to address bug fixes, improve compatibility with `vue-tsc`, and introduce new configuration options like `organizeImportsTypeOrder`. A key differentiator is its reliance on the robust TypeScript language service for import logic, offering zero-config setup for Prettier v2 users and minimal configuration for Prettier v3. It acts by extending and overriding Prettier's built-in parsers, meaning it's incompatible with other plugins that attempt to do the same for `babel`, `typescript`, or `vue` parsers. It primarily manages peer dependencies `prettier`, `typescript`, and optionally `vue-tsc` for Vue.js support.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install prettier-plugin-organize-imports"],"cli":null},"imports":["{\n  \"plugins\": [\n    \"prettier-plugin-organize-imports\"\n  ]\n}","/* No explicit configuration needed for Prettier v2; automatic discovery is enabled by default. */","{\n  \"organizeImportsSkipDestructiveCodeActions\": true\n}"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"{\n  \"name\": \"my-project\",\n  \"version\": \"1.0.0\",\n  \"devDependencies\": {\n    \"prettier\": \"^3.0.0\",\n    \"typescript\": \"^5.0.0\",\n    \"prettier-plugin-organize-imports\": \"^4.0.0\"\n  }\n}\n\n// .prettierrc.json\n{\n  \"plugins\": [\n    \"prettier-plugin-organize-imports\"\n  ]\n}\n\n// src/main.ts (before formatting)\nimport { z } from \"./utils\";\nimport type { Bar } from './types';\nimport { foo } from \"./helpers\";\n\n\nconst myVar: Bar = foo + z;\n\nconsole.log(myVar);\n\n// Terminal command to format:\n// npx prettier --write \"src/**/*.ts\"\n","lang":"typescript","description":"This quickstart demonstrates installing the plugin and configuring Prettier v3 to automatically organize imports in a TypeScript project upon formatting.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}