{"id":13495433,"url":"https://github.com/azat-io/eslint-plugin-perfectionist","last_synced_at":"2026-02-05T06:04:38.216Z","repository":{"id":162482661,"uuid":"636870455","full_name":"azat-io/eslint-plugin-perfectionist","owner":"azat-io","description":"☂️ ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.","archived":false,"fork":false,"pushed_at":"2025-05-06T09:26:00.000Z","size":13693,"stargazers_count":2549,"open_issues_count":17,"forks_count":49,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-05-11T03:47:15.058Z","etag":null,"topics":["eslint","eslint-plugin","eslint-rules","perfectionist"],"latest_commit_sha":null,"homepage":"https://perfectionist.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azat-io.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.config.json","contributing":"contributing.md","funding":null,"license":"license.md","code_of_conduct":".github/code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-05T21:04:44.000Z","updated_at":"2025-05-09T22:20:27.000Z","dependencies_parsed_at":"2023-10-13T11:27:16.580Z","dependency_job_id":"550170b9-1b40-4d21-a391-4ce154b6524f","html_url":"https://github.com/azat-io/eslint-plugin-perfectionist","commit_stats":null,"previous_names":[],"tags_count":79,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azat-io%2Feslint-plugin-perfectionist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azat-io%2Feslint-plugin-perfectionist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azat-io%2Feslint-plugin-perfectionist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azat-io%2Feslint-plugin-perfectionist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azat-io","download_url":"https://codeload.github.com/azat-io/eslint-plugin-perfectionist/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253514559,"owners_count":21920334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","eslint-plugin","eslint-rules","perfectionist"],"created_at":"2024-07-31T19:01:34.711Z","updated_at":"2026-02-05T06:04:38.203Z","avatar_url":"https://github.com/azat-io.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Plugins"],"sub_categories":["Style"],"readme":"# ESLint Plugin Perfectionist\n\n\u003cimg\n  src=\"https://raw.githubusercontent.com/azat-io/eslint-plugin-perfectionist/main/docs/public/logo.svg\"\n  alt=\"ESLint Plugin Perfectionist logo\"\n  align=\"right\"\n  height=\"160\"\n  width=\"160\"\n/\u003e\n\n[![Version](https://img.shields.io/npm/v/eslint-plugin-perfectionist.svg?color=4a32c3\u0026labelColor=26272b)](https://npmjs.com/package/eslint-plugin-perfectionist)\n[![Monthly Download](https://img.shields.io/npm/dm/eslint-plugin-perfectionist.svg?color=4a32c3\u0026labelColor=26272b)](https://npmjs.com/package/eslint-plugin-perfectionist)\n[![Code Coverage](https://img.shields.io/codecov/c/github/azat-io/eslint-plugin-perfectionist.svg?color=4a32c3\u0026labelColor=26272b)](https://npmjs.com/package/eslint-plugin-perfectionist)\n[![GitHub License](https://img.shields.io/badge/license-MIT-232428.svg?color=4a32c3\u0026labelColor=26272b)](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/license.md)\n\nAn ESLint plugin that sets rules to format your code and make it consistent.\n\nThis plugin defines rules for sorting various data, such as objects, imports,\nTypeScript types, enums, JSX props, Svelte attributes, etc. alphabetically,\nnaturally, or by line length.\n\nAll rules are automatically fixable. It's safe!\n\n## Why\n\nSorting imports and properties in software development offers numerous benefits:\n\n- **Readability**: Finding declarations in a sorted, large list is a little\n  faster. Remember that you read the code much more often than you write it.\n\n- **Maintainability**: Sorting imports and properties is considered a good\n  practice in software development, contributing to code quality and consistency\n  across the codebase.\n\n- **Code Review and Collaboration**: If you set rules that say you can only do\n  things one way, no one will have to spend time thinking about how to do it.\n\n- **Code Uniformity**: When all code looks exactly the same, it is very hard to\n  see who wrote it, which makes achieving the lofty goal of _collective code\n  ownership_ easier.\n\n- **Aesthetics**: This not only provides functional benefits, but also gives the\n  code an aesthetic appeal, visually pleasing and harmonious structure. Take\n  your code to a beauty salon!\n\n## Documentation\n\nSee [docs](https://perfectionist.dev).\n\n### Alphabetical Sorting\n\n\u003cpicture\u003e\n  \u003csource\n    srcset=\"https://raw.githubusercontent.com/azat-io/eslint-plugin-perfectionist/main/docs/public/examples/example-alphabetical-light.webp\"\n    media=\"(prefers-color-scheme: light)\"\n  /\u003e\n  \u003csource\n    srcset=\"https://raw.githubusercontent.com/azat-io/eslint-plugin-perfectionist/main/docs/public/examples/example-alphabetical-dark.webp\"\n    media=\"(prefers-color-scheme: dark)\"\n  /\u003e\n  \u003cimg\n    src=\"https://raw.githubusercontent.com/azat-io/eslint-plugin-perfectionist/main/docs/public/examples/example-alphabetical-light.webp\"\n    alt=\"ESLint Plugin Perfectionist alphabetical usage example\"\n  /\u003e\n\u003c/picture\u003e\n\n### Sorting by Line Length\n\n\u003cpicture\u003e\n  \u003csource\n    srcset=\"https://raw.githubusercontent.com/azat-io/eslint-plugin-perfectionist/main/docs/public/examples/example-line-length-light.webp\"\n    media=\"(prefers-color-scheme: light)\"\n  /\u003e\n  \u003csource\n    srcset=\"https://raw.githubusercontent.com/azat-io/eslint-plugin-perfectionist/main/docs/public/examples/example-line-length-dark.webp\"\n    media=\"(prefers-color-scheme: dark)\"\n  /\u003e\n  \u003cimg\n    src=\"https://raw.githubusercontent.com/azat-io/eslint-plugin-perfectionist/main/docs/public/examples/example-line-length-light.webp\"\n    alt=\"ESLint Plugin Perfectionist line length usage example\"\n  /\u003e\n\u003c/picture\u003e\n\n## Installation\n\nYou'll first need to install [ESLint](https://eslint.org) v8.45.0 or greater:\n\n```sh\nnpm install --save-dev eslint\n```\n\nNext, install `eslint-plugin-perfectionist`:\n\n```sh\nnpm install --save-dev eslint-plugin-perfectionist\n```\n\n## Usage\n\nAdd `eslint-plugin-perfectionist` to the plugins section of the ESLint\nconfiguration file and define the list of rules you will use.\n\n### Flat Config ([`eslint.config.js`](https://eslint.org/docs/latest/use/configure/configuration-files))\n\n```js\nimport perfectionist from 'eslint-plugin-perfectionist'\n\nexport default [\n  {\n    plugins: {\n      perfectionist,\n    },\n    rules: {\n      'perfectionist/sort-imports': [\n        'error',\n        {\n          type: 'natural',\n          order: 'asc',\n        },\n      ],\n    },\n  },\n]\n```\n\n### Legacy Config ([`.eslintrc.js`](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated))\n\n\u003c!-- prettier-ignore --\u003e\n```js\nmodule.exports = {\n  plugins: [\n    'perfectionist',\n  ],\n  rules: {\n    'perfectionist/sort-imports': [\n      'error',\n      {\n        type: 'natural',\n        order: 'asc',\n      }\n    ]\n  }\n}\n```\n\n## Configs\n\nThe easiest way to use `eslint-plugin-perfectionist` is to use ready-made\nconfigs. Config files use all the rules of the current plugin, but you can\noverride them.\n\n### Flat Config ([`eslint.config.js`](https://eslint.org/docs/latest/use/configure/configuration-files))\n\n\u003c!-- prettier-ignore --\u003e\n```js\nimport perfectionist from 'eslint-plugin-perfectionist'\n\nexport default [\n  perfectionist.configs['recommended-natural'],\n]\n```\n\n### Legacy Config ([`.eslintrc.js`](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated))\n\n\u003c!-- prettier-ignore --\u003e\n```js\nmodule.exports = {\n  extends: [\n    'plugin:perfectionist/recommended-natural-legacy',\n  ],\n}\n```\n\n### List of Configs\n\n| Name                                                                                   | Description                                                      |\n| :------------------------------------------------------------------------------------- | :--------------------------------------------------------------- |\n| [recommended-alphabetical](https://perfectionist.dev/configs/recommended-alphabetical) | All plugin rules with alphabetical sorting in ascending order    |\n| [recommended-natural](https://perfectionist.dev/configs/recommended-natural)           | All plugin rules with natural sorting in ascending order         |\n| [recommended-line-length](https://perfectionist.dev/configs/recommended-line-length)   | All plugin rules with sorting by line length in descending order |\n| [recommended-custom](https://perfectionist.dev/configs/recommended-custom)             | All plugin rules with sorting by your own custom order           |\n\n## Rules\n\n\u003c!-- begin auto-generated rules list --\u003e\n\n🔧 Automatically fixable by the\n[`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\n\n| Name                                                                                     | Description                                   | 🔧  |\n| :--------------------------------------------------------------------------------------- | :-------------------------------------------- | :-- |\n| [sort-array-includes](https://perfectionist.dev/rules/sort-array-includes)               | Enforce sorted arrays before include method   | 🔧  |\n| [sort-classes](https://perfectionist.dev/rules/sort-classes)                             | Enforce sorted classes                        | 🔧  |\n| [sort-decorators](https://perfectionist.dev/rules/sort-decorators)                       | Enforce sorted decorators                     | 🔧  |\n| [sort-enums](https://perfectionist.dev/rules/sort-enums)                                 | Enforce sorted TypeScript enums               | 🔧  |\n| [sort-export-attributes](https://perfectionist.dev/rules/sort-export-attributes)         | Enforce sorted export attributes              | 🔧  |\n| [sort-exports](https://perfectionist.dev/rules/sort-exports)                             | Enforce sorted exports                        | 🔧  |\n| [sort-heritage-clauses](https://perfectionist.dev/rules/sort-heritage-clauses)           | Enforce sorted `implements`/`extends` clauses | 🔧  |\n| [sort-import-attributes](https://perfectionist.dev/rules/sort-import-attributes)         | Enforce sorted import attributes              | 🔧  |\n| [sort-imports](https://perfectionist.dev/rules/sort-imports)                             | Enforce sorted imports                        | 🔧  |\n| [sort-interfaces](https://perfectionist.dev/rules/sort-interfaces)                       | Enforce sorted interface properties           | 🔧  |\n| [sort-intersection-types](https://perfectionist.dev/rules/sort-intersection-types)       | Enforce sorted intersection types             | 🔧  |\n| [sort-jsx-props](https://perfectionist.dev/rules/sort-jsx-props)                         | Enforce sorted JSX props                      | 🔧  |\n| [sort-maps](https://perfectionist.dev/rules/sort-maps)                                   | Enforce sorted Map elements                   | 🔧  |\n| [sort-modules](https://perfectionist.dev/rules/sort-modules)                             | Enforce sorted modules                        | 🔧  |\n| [sort-named-exports](https://perfectionist.dev/rules/sort-named-exports)                 | Enforce sorted named exports                  | 🔧  |\n| [sort-named-imports](https://perfectionist.dev/rules/sort-named-imports)                 | Enforce sorted named imports                  | 🔧  |\n| [sort-object-types](https://perfectionist.dev/rules/sort-object-types)                   | Enforce sorted object types                   | 🔧  |\n| [sort-objects](https://perfectionist.dev/rules/sort-objects)                             | Enforce sorted objects                        | 🔧  |\n| [sort-sets](https://perfectionist.dev/rules/sort-sets)                                   | Enforce sorted Set elements                   | 🔧  |\n| [sort-switch-case](https://perfectionist.dev/rules/sort-switch-case)                     | Enforce sorted switch case statements         | 🔧  |\n| [sort-union-types](https://perfectionist.dev/rules/sort-union-types)                     | Enforce sorted union types                    | 🔧  |\n| [sort-variable-declarations](https://perfectionist.dev/rules/sort-variable-declarations) | Enforce sorted variable declarations          | 🔧  |\n\n\u003c!-- end auto-generated rules list --\u003e\n\n## FAQ\n\n### Can I automatically fix problems in the editor?\n\nYes. To do this, you need to enable autofix in ESLint when you save the file in\nyour editor. You may find instructions for your editor\n[here](https://perfectionist.dev/guide/integrations).\n\n### Is it safe?\n\nOverall, yes. We want to make sure that the work of the plugin does not\nnegatively affect the behavior of the code. For example, the plugin takes into\naccount spread operators in JSX and objects, comments to the code. Safety is our\npriority. If you encounter any problem, you can create an\n[issue](https://github.com/azat-io/eslint-plugin-perfectionist/issues/new/choose).\n\n### Why not use Prettier?\n\nI love Prettier. However, this is not its area of responsibility. Prettier is\nused for formatting, and ESLint for styling. For example, changing the order of\nimports can affect how the code works (console.log calls, fetch, style loading).\nPrettier should not change the AST. There is a cool article about this:\n[\"The Blurry Line Between Formatting and Style\"](https://blog.joshuakgoldberg.com/the-blurry-line-between-formatting-and-style)\nby **@joshuakgoldberg**.\n\n## Versioning Policy\n\nThis plugin is following [Semantic Versioning](https://semver.org/) and\n[ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy).\n\n## Contributing\n\nSee\n[Contributing Guide](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/contributing.md).\n\n## License\n\nMIT \u0026copy; [Azat S.](https://azat.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazat-io%2Feslint-plugin-perfectionist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazat-io%2Feslint-plugin-perfectionist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazat-io%2Feslint-plugin-perfectionist/lists"}