{"id":20372,"library":"prettier-plugin-import-sort","title":"prettier-plugin-import-sort","description":"A Prettier plugin (v0.0.7, no recent releases) that integrates import-sort into Prettier to automatically sort JavaScript and TypeScript import statements. It requires import-sort style modules like import-sort-style-module and is configured via package.json or config files. The plugin acts as a bridge, applying import-sort's sorting logic during Prettier formatting. It is unmaintained since 2020 and users are advised to migrate to alternatives like @trivago/prettier-plugin-sort-imports or eslint-plugin-import for active support.","status":"deprecated","version":"0.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/ggascoigne/prettier-plugin-import-sort#readme","tags":["javascript","prettier","import-sort","plugin"],"install":[{"cmd":"npm install prettier-plugin-import-sort","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-import-sort","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-import-sort","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: requires Prettier >= 2.0","package":"prettier","optional":false},{"reason":"needed for the import sorting style; must be installed separately","package":"import-sort-style-module","optional":true}],"imports":[{"note":"Prettier plugins are not imported in code; they are listed in .prettierrc or detected automatically when installed.","wrong":"import prettierPluginImportSort from 'prettier-plugin-import-sort';","symbol":"default","correct":"No import statement needed; plugin is auto-detected by Prettier."},{"note":"Prettier discovers plugins via node_modules; no explicit require is correct.","wrong":"const plugin = require('prettier-plugin-import-sort');","symbol":"require('prettier-plugin-import-sort')","correct":"No require needed; plugin auto-loads."},{"note":"Plugin is a string, not an object. This is for .prettierrc JSON; plugins key is used to explicitly list plugins.","wrong":"{\n  \"plugins\": [\"prettier-plugin-import-sort\", {}]\n}","symbol":"plugins in .prettierrc","correct":"{\n  \"plugins\": [\"prettier-plugin-import-sort\"]\n}"}],"quickstart":{"code":"// Install dependencies\nnpm install -D prettier prettier-plugin-import-sort import-sort-style-module\n\n// package.json configuration\n{\n  \"importSort\": {\n    \".js, .jsx, .ts, .tsx\": {\n      \"style\": \"module\"\n    }\n  },\n  \"prettier\": {\n    \"plugins\": [\"prettier-plugin-import-sort\"]\n  }\n}\n\n// Example input file\nimport { z } from 'z';\nimport { a } from 'a';\n\n// Run Prettier\nnpx prettier --write input.js\n\n// Sorted output\nimport { a } from 'a';\nimport { z } from 'z';","lang":"javascript","description":"Shows setup and usage: install deps, configure importSort style and Prettier plugin, then format a file to sort imports."},"warnings":[{"fix":"Replace with @trivago/prettier-plugin-sort-imports or eslint-plugin-import.","message":"This plugin is no longer maintained. Consider using @trivago/prettier-plugin-sort-imports.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Ensure extension list in importSort config is exactly '.js, .jsx, .ts, .tsx' (commas and spaces). Avoid patterns like '*.js'.","message":"importSort silently falls back to default configuration on setup errors, making debugging difficult.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Install a style module (e.g., import-sort-style-module) and verify by running Prettier with --log-level debug.","message":"Fails silently if no import-sort style module is installed; no warnings are shown.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add 'parser': 'typescript' to importSort config if using TypeScript with decorators.","message":"TypeScript-specific parser may be required for advanced syntax like decorators, but misconfiguration goes unnoticed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use a Prettier v2-compatible version or switch to a maintained plugin.","message":"Not compatible with Prettier v3+ due to internal plugin system changes.","severity":"breaking","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install -D import-sort-style-module","cause":"Missing the import-sort style package in node_modules.","error":"Error: Cannot find module 'import-sort-style-module'"},{"fix":"Upgrade Prettier to >= 2.0 or use prettier.resolveConfig.sync() method.","cause":"Prettier version < 2.0 does not support plugins array in config.","error":"Ignored unknown option {plugins}"},{"fix":"Check that 'importSort' key in package.json has correct structure with file extension mapping.","cause":"importSort configuration is malformed or missing, causing import-sort to fail.","error":"Cannot read property 'sort' of undefined"},{"fix":"Ensure you are formatting a file with an appropriate extension (.js, .ts, etc.) or specify --parser.","cause":"Prettier cannot determine file type; needed for import-sort plugin.","error":"No parser and no filepath given, using 'babel'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}