Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/infctr/eslint-plugin-typescript-sort-keys
A linter plugin to require sorting interface and string enum keys
https://github.com/infctr/eslint-plugin-typescript-sort-keys
eslint eslint-plugin typescript
Last synced: 25 days ago
JSON representation
A linter plugin to require sorting interface and string enum keys
- Host: GitHub
- URL: https://github.com/infctr/eslint-plugin-typescript-sort-keys
- Owner: infctr
- License: isc
- Created: 2019-01-21T10:21:42.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-12T15:20:39.000Z (3 months ago)
- Last Synced: 2024-09-29T01:05:34.719Z (about 1 month ago)
- Topics: eslint, eslint-plugin, typescript
- Language: TypeScript
- Size: 699 KB
- Stars: 143
- Watchers: 2
- Forks: 28
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
![Tests](https://github.com/infctr/eslint-plugin-typescript-sort-keys/workflows/Tests/badge.svg?branch=master)
# eslint-plugin-typescript-sort-keys
Sort interface and string enum keys
Inspired by and sourced from [eslint/sort-keys]([https://github.com/eslint/eslint/blob/master/docs/rules/sort-keys.md](https://github.com/eslint/eslint/blob/main/docs/src/rules/sort-keys.md))
## Installation
You'll first need to install
- [eslint](http://eslint.org)
- [typescript](http://www.typescriptlang.org/)
- [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser)```sh
yarn add -D eslint typescript @typescript-eslint/parser
```Next, install `eslint-plugin-typescript-sort-keys`:
```sh
yarn add -D eslint-plugin-typescript-sort-keys
```**Note:** If you installed ESLint globally then you must also install `eslint-plugin-typescript-sort-keys` globally.
## Usage
Specify the parser for typescript files in your `.eslintrc` configuration file:
```json
{
"parser": "@typescript-eslint/parser"
}
```Add `typescript-sort-keys` to the plugins section. You can omit the `eslint-plugin-` prefix:
```json
{
"plugins": ["typescript-sort-keys"]
}
```Then configure the rules you want to use under the rules section.
```json
{
"rules": {
"typescript-sort-keys/interface": "error",
"typescript-sort-keys/string-enum": "error"
}
}
```Or enable all rules with defaults
```json
{
"extends": ["plugin:typescript-sort-keys/recommended"]
}
```## Supported Rules
**Key**: :heavy_check_mark: = recommended, :wrench: = fixable
| Name | Description | :heavy_check_mark: | :wrench: |
| ---- | ----------- | ------------------ | -------- |
| [`typescript-sort-keys/interface`](./docs/rules/interface.md) | require interface keys to be sorted | :heavy_check_mark: | :wrench: |
| [`typescript-sort-keys/string-enum`](./docs/rules/string-enum.md) | require string enum members to be sorted | :heavy_check_mark: | :wrench: |