Registry /
testing / eslint-plugin-perfectionist
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default export (plugin object)
✓ import perfectionist from 'eslint-plugin-perfectionist'
✗ const perfectionist = require('eslint-plugin-perfectionist')
Plugin is ESM-only since v3. Use import in flat config; require() will not work in CJS projects.
sort-imports rule
✓ import perfectionist from 'eslint-plugin-perfectionist'; export default [ { plugins: { perfectionist }, rules: { 'perfectionist/sort-imports': 'error' } } ]
✗ module.exports = { rules: { 'perfectionist/sort-imports': 'error' } }
Flat config requires the plugin object in 'plugins' key. Legacy .eslintrc format is deprecated in favor of flat config.
configs (recommended)
✓ import perfectionist from 'eslint-plugin-perfectionist'; export default [...perfectionist.configs['recommended-alphabetical']]
✗ module.exports = { extends: ['plugin:perfectionist/recommended-alphabetical'] }
Configs are exported as arrays for flat config. Legacy 'extends' string works only with old ESLint config format.
sort-objects rule
✓ import perfectionist from 'eslint-plugin-perfectionist'; export default [ { plugins: { perfectionist }, rules: { 'perfectionist/sort-objects': ['error', { type: 'alphabetical' }] } } ]
Each rule accepts options like 'type' (alphabetical, line-length, natural) and custom groups.
Shows flat config setup with recommended alphabetical config and custom sort-imports rule options.
// eslint.config.js
import js from '@eslint/js';
import perfectionist from 'eslint-plugin-perfectionist';
export default [
js.configs.recommended,
...perfectionist.configs['recommended-alphabetical'],
{
rules: {
'perfectionist/sort-imports': ['error', {
type: 'alphabetical',
order: 'asc',
ignoreCase: true,
newlinesBetween: 'ignore',
groups: [
'type',
'internal',
'external',
'builtin',
'parent',
'sibling',
'index',
'object',
'style',
'side-effect',
'unknown',
],
customGroups: { value: {}, type: {} },
}],
},
},
];
Errors
Common errors & fixes
Error: Failed to load plugin 'perfectionist' declared in 'plugins': Cannot find module 'eslint-plugin-perfectionist'
Missing npm install or incorrect import path in flat config.
fixRun 'npm install --save-dev eslint-plugin-perfectionist' and ensure import uses correct name.
TypeError: Cannot read properties of undefined (reading 'sort-imports')
Using string rule name without registering plugin object in flat config.
fixAdd 'plugins: { perfectionist }' to the flat config object. Configuration for rule 'perfectionist/sort-imports' is invalid: Unknown option 'type'
Using option 'type' in legacy config where it may not be recognized.
fixUpdate to flat config or use correct options for your version; check documentation.
Error: Requires ESLint >=8.45.0
Installed ESLint version is too old.
fixUpgrade ESLint to v8.45.0 or higher (v9/v10 also supported).
Cannot find module 'eslint-plugin-perfectionist' or its corresponding type declarations.
Missing TypeScript type declarations; the package ships types, but IDE may not pick them up.
fixEnsure 'eslint-plugin-perfectionist' is installed and tsconfig.json includes 'node_modules' in 'types' or uses 'skipLibCheck'.
Audit
Dependencies
eslintrequiredpeer dependency, required as the hosting linter