Getting Started
Before you start, take a moment to support the project by giving us a star on GitHub.
Your support helps the continued development and improvement of this project.
Installation
Okay, let’s get started. You’ll first need to install ESLint:
Next, install eslint-plugin-perfectionist
:
Usage
Add perfectionist
to the plugins section of your ESLint configuration. Then configure the rules you want to use under the rules section.
Settings
Many rules have common settings. You can set them in the settings
field.
The highest priority is given to the settings of a particular rule. Next comes the settings field and the lowest priority has default values.
In settings you can set the following options:
type
— The type of sorting. Possible values are'alphabetical'
,'natural'
and'line-length'
.order
— The order of sorting. Possible values are'asc'
and'desc'
.ignoreCase
— Ignore case when sorting.ignorePattern
— Ignore sorting for elements that match the pattern.specialCharacters
— Control whether special characters should be kept, trimmed or removed before sorting. Values can be'keep'
,'trim'
or'remove'
.locales
- The locales of sorting. Values can be a string with a BCP 47 language tag, or an array of such strings. See String.prototype.localeCompare() - locales.partitionByComment
— Partition the sorted elements by comments. Values can betrue
,false
or regexp pattern.partitionByNewLine
— Partition the sorted elements by new lines. Values can betrue
orfalse
.
Example: