{"id":19870,"library":"eslint-plugin-perfectionist","title":"ESLint Plugin Perfectionist","description":"An ESLint plugin that enforces sorting of various data structures including objects, imports, TypeScript types, enums, JSX props, Svelte attributes, and more. Current stable version is 5.9.0 with frequent releases (multiple per month). Supports ESLint v8.45+, v9, and v10. All rules are auto-fixable. Key differentiators: supports multiple sort orders (alphabetical, natural, line-length), highly configurable with group/partition/selector options, and covers broader range of structures than alternatives like eslint-plugin-simple-import-sort or eslint-plugin-import.","status":"active","version":"5.9.0","language":"javascript","source_language":"en","source_url":"https://github.com/azat-io/eslint-plugin-perfectionist","tags":["javascript","eslint","eslint-plugin","perfectionist","typescript"],"install":[{"cmd":"npm install eslint-plugin-perfectionist","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-perfectionist","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-perfectionist","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, required as the hosting linter","package":"eslint","optional":false}],"imports":[{"note":"Plugin is ESM-only since v3. Use import in flat config; require() will not work in CJS projects.","wrong":"const perfectionist = require('eslint-plugin-perfectionist')","symbol":"default export (plugin object)","correct":"import perfectionist from 'eslint-plugin-perfectionist'"},{"note":"Flat config requires the plugin object in 'plugins' key. Legacy .eslintrc format is deprecated in favor of flat config.","wrong":"module.exports = { rules: { 'perfectionist/sort-imports': 'error' } }","symbol":"sort-imports rule","correct":"import perfectionist from 'eslint-plugin-perfectionist'; export default [ { plugins: { perfectionist }, rules: { 'perfectionist/sort-imports': 'error' } } ]"},{"note":"Configs are exported as arrays for flat config. Legacy 'extends' string works only with old ESLint config format.","wrong":"module.exports = { extends: ['plugin:perfectionist/recommended-alphabetical'] }","symbol":"configs (recommended)","correct":"import perfectionist from 'eslint-plugin-perfectionist'; export default [...perfectionist.configs['recommended-alphabetical']]"},{"note":"Each rule accepts options like 'type' (alphabetical, line-length, natural) and custom groups.","wrong":"","symbol":"sort-objects rule","correct":"import perfectionist from 'eslint-plugin-perfectionist'; export default [ { plugins: { perfectionist }, rules: { 'perfectionist/sort-objects': ['error', { type: 'alphabetical' }] } } ]"}],"quickstart":{"code":"// eslint.config.js\nimport js from '@eslint/js';\nimport perfectionist from 'eslint-plugin-perfectionist';\n\nexport default [\n  js.configs.recommended,\n  ...perfectionist.configs['recommended-alphabetical'],\n  {\n    rules: {\n      'perfectionist/sort-imports': ['error', {\n        type: 'alphabetical',\n        order: 'asc',\n        ignoreCase: true,\n        newlinesBetween: 'ignore',\n        groups: [\n          'type',\n          'internal',\n          'external',\n          'builtin',\n          'parent',\n          'sibling',\n          'index',\n          'object',\n          'style',\n          'side-effect',\n          'unknown',\n        ],\n        customGroups: { value: {}, type: {} },\n      }],\n    },\n  },\n];","lang":"typescript","description":"Shows flat config setup with recommended alphabetical config and custom sort-imports rule options."},"warnings":[{"fix":"Upgrade to ESLint v8+ and migrate to flat config (eslint.config.js).","message":"v3 dropped support for ESLint < 8 and CJS configuration.","severity":"breaking","affected_versions":">=3.0.0 <4.0.0"},{"fix":"Update Node.js to version 20.x or 22.x.","message":"v5 requires Node.js >=20.0.0 or >=22.0.0.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Include 'side-effect' in the 'groups' array if you want side-effect imports sorted separately.","message":"The 'sort-imports' rule does not automatically group side-effect imports; they must be explicitly in a 'side-effect' group.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use 'alphabetical' type or disable conflicting formatting rules.","message":"Some rules may conflict with Prettier or other formatters when sorting by line-length.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Switch to eslint.config.js flat config.","message":"The legacy .eslintrc format is deprecated; flat config is recommended.","severity":"deprecated","affected_versions":">=4.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 --save-dev eslint-plugin-perfectionist' and ensure import uses correct name.","cause":"Missing npm install or incorrect import path in flat config.","error":"Error: Failed to load plugin 'perfectionist' declared in 'plugins': Cannot find module 'eslint-plugin-perfectionist'"},{"fix":"Add 'plugins: { perfectionist }' to the flat config object.","cause":"Using string rule name without registering plugin object in flat config.","error":"TypeError: Cannot read properties of undefined (reading 'sort-imports')"},{"fix":"Update to flat config or use correct options for your version; check documentation.","cause":"Using option 'type' in legacy config where it may not be recognized.","error":"Configuration for rule 'perfectionist/sort-imports' is invalid: Unknown option 'type'"},{"fix":"Upgrade ESLint to v8.45.0 or higher (v9/v10 also supported).","cause":"Installed ESLint version is too old.","error":"Error: Requires ESLint >=8.45.0"},{"fix":"Ensure 'eslint-plugin-perfectionist' is installed and tsconfig.json includes 'node_modules' in 'types' or uses 'skipLibCheck'.","cause":"Missing TypeScript type declarations; the package ships types, but IDE may not pick them up.","error":"Cannot find module 'eslint-plugin-perfectionist' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}