Skip to content

infctr/eslint-plugin-typescript-sort-keys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Nov 23, 2021
7605d7e · Nov 23, 2021
Oct 15, 2021
May 22, 2020
Oct 14, 2021
Aug 16, 2021
Jan 19, 2019
May 2, 2020
Aug 16, 2021
May 2, 2020
May 22, 2020
May 12, 2020
May 22, 2020
May 18, 2020
Nov 23, 2021
Apr 2, 2020
May 21, 2020
May 22, 2020
May 22, 2020
May 22, 2020
Nov 23, 2021
May 22, 2020
May 21, 2020
Nov 22, 2021

Repository files navigation

Tests

eslint-plugin-typescript-sort-keys

Sort interface and string enum keys

Inspired by and sourced from eslint/sort-keys

Installation

You'll first need to install

yarn add -D eslint typescript @typescript-eslint/parser

Next, install eslint-plugin-typescript-sort-keys:

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:

{
  "parser": "@typescript-eslint/parser"
}

Add typescript-sort-keys to the plugins section. You can omit the eslint-plugin- prefix:

{
  "plugins": ["typescript-sort-keys"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "typescript-sort-keys/interface": "error",
    "typescript-sort-keys/string-enum": "error"
  }
}

Or enable all rules with defaults

{
  "extends": ["plugin:typescript-sort-keys/recommended"]
}

Supported Rules

Key: ✔️ = recommended, 🔧 = fixable

Name Description ✔️ 🔧
typescript-sort-keys/interface require interface keys to be sorted ✔️ 🔧
typescript-sort-keys/string-enum require string enum members to be sorted ✔️ 🔧