Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nirtamir2/eslint-plugin-sort-export-all
ESLint rule that helps sort export *
https://github.com/nirtamir2/eslint-plugin-sort-export-all
eslint eslint-plugin eslint-rules exports javascript library sort typescript
Last synced: 9 days ago
JSON representation
ESLint rule that helps sort export *
- Host: GitHub
- URL: https://github.com/nirtamir2/eslint-plugin-sort-export-all
- Owner: nirtamir2
- Created: 2020-07-08T10:27:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-04-25T23:13:01.000Z (almost 2 years ago)
- Last Synced: 2025-01-15T20:10:21.977Z (25 days ago)
- Topics: eslint, eslint-plugin, eslint-rules, exports, javascript, library, sort, typescript
- Language: TypeScript
- Homepage:
- Size: 653 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# eslint-plugin-sort-export-all
ESLint rule that sorts `exports *` with autofix enabled
[![npm version](https://badge.fury.io/js/eslint-plugin-sort-export-all.svg)](https://badge.fury.io/js/eslint-plugin-sort-export-all)
![Example](./example.gif)
## Installation
You'll first need to install [ESLint](http://eslint.org):
```
$ npm i eslint --save-dev
$ yarn add eslint --dev
$ pnpm add -D eslint
```Next, install `eslint-plugin-sort-export-all`:
```
$ npm install eslint-plugin-sort-export-all --save-dev
$ yarn add eslint-plugin-sort-export-all --dev
$ pnpm add -D eslint-plugin-sort-export-all
```**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-sort-export-all` globally.
## Usage
Add `sort-export-all` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
```json
{
"plugins": ["sort-export-all"]
}
```Then configure the rule under the rules section.
```json
{
"rules": {
"sort-export-all/sort-export-all": "warn"
}
}
```Or enable it with defaults
```json
{
"extends": ["plugin:sort-export-all/recommended"]
}
```Often it makes sense to enable `sort-export-all` only for certain files/directories. For cases like that, use override key of eslint config:
```jsonc
{
"plugins": ["sort-export-all"],
"rules": {
"sort-export-all/sort-export-all": "off"
},
"overrides": [
{
"files": ["src/**/index.{ts,js}"],
"rules": {
"sort-export-all/sort-export-all": "error"
}
}
]
}
```If you use TypeScript,
make sure to use [ @typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint) as parser for better compatability.## Rule configuration
- The 1st option is `"asc"` or `"desc"`.
`"asc"` (default) - enforce properties to be in ascending order.
`"desc"` - enforce properties to be in descending order.
- The 2nd option is an object which has 3 properties.
`caseSensitive` - if `true`, enforce properties to be in case-sensitive order. Default is `true`.
`natural` - if `true`, enforce properties to be in natural order. Default is false. Natural Order compares strings containing a combination of letters and numbers in the way a human being would sort. It basically sorts numerically, instead of sorting alphabetically. So the number 10 comes after the number `3` in Natural Sorting.
```
Standard sorting: Natural order sorting:
img1.png img1.png
img10.png img2.png
img12.png img10.png
img2.png img12.png
```The default config is
```javascript
[
"warn",
"asc",
{
caseSensitive: true,
natural: false,
},
];
```