An ESLint plugin that sets rules to format your code and make it consistent.
This plugin defines rules for sorting various data, such as objects, imports,
TypeScript types, enums, JSX props, Svelte attributes, etc. alphabetically,
naturally, or by line length.
All rules are automatically fixable. It's safe!
Why
Sorting imports and properties in software development offers numerous benefits:
Readability: Finding declarations in a sorted, large list is a little
faster. Remember that you read the code much more often than you write it.
Maintainability: Sorting imports and properties is considered a good
practice in software development, contributing to code quality and consistency
across the codebase.
Code Review and Collaboration: If you set rules that say you can only do
things one way, no one will have to spend time thinking about how to do it.
Code Uniformity: When all code looks exactly the same, it is very hard to
see who wrote it, which makes achieving the lofty goal of collective code
ownership easier.
Aesthetics: This not only provides functional benefits, but also gives the
code an aesthetic appeal, visually pleasing and harmonious structure. Take
your code to a beauty salon!
The easiest way to use eslint-plugin-perfectionist is to use ready-made
configs. Config files use all the rules of the current plugin, but you can
override them.
Yes. To do this, you need to enable autofix in ESLint when you save the file in
your editor. You may find instructions for your editor
here.
Is it safe?
Overall, yes. We want to make sure that the work of the plugin does not
negatively affect the behavior of the code. For example, the plugin takes into
account spread operators in JSX and objects, comments to the code. Safety is our
priority. If you encounter any problem, you can create an
issue.
Why not use Prettier?
I love Prettier. However, this is not its area of responsibility. Prettier is
used for formatting, and ESLint for styling. For example, changing the order of
imports can affect how the code works (console.log calls, fetch, style loading).
Prettier should not change the AST. There is a cool article about this:
"The Blurry Line Between Formatting and Style"
by @joshuakgoldberg.
eslint-plugin-import is a popular ESLint plugin that provides rules for ensuring proper import/export syntax and order. It focuses on managing module imports and exports, ensuring they are used correctly and consistently.
eslint-plugin-sort-keys-fix is an ESLint plugin that automatically sorts object keys in a consistent order. It is similar to the 'sort-keys' rule in eslint-plugin-perfectionist but focuses specifically on object keys.
eslint-plugin-jsdoc is an ESLint plugin that enforces JSDoc comments and their formatting. While it doesn't focus on sorting, it helps maintain consistent documentation style, which complements the goals of eslint-plugin-perfectionist.
ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
The npm package eslint-plugin-perfectionist receives a total of 1,540,883 weekly downloads. As such, eslint-plugin-perfectionist popularity was classified as popular.
We found that eslint-plugin-perfectionist demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.
Package last updated on 18 Apr 2026
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.