Skip to content

Latest commit

 

History

History
116 lines (87 loc) · 2.14 KB

sort-on-accessors.md

File metadata and controls

116 lines (87 loc) · 2.14 KB

Enforces order of accessors decorators (sort-decorators/sort-on-accessors)

💼⚠️ This rule is enabled in the 🔒 strict config. This rule warns in the ✅ recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

Sort decorators on accessors.

Options

Name Description value
autoFix Automatically fix the order.
Decorators order can matter at runtime.
boolean
caseSensitive If true, enforce properties to be in case-sensitive order. boolean
direction Specify the direction of the ordering. asc | desc

Definitive information in the JSON schema.

Defaults

This is the default values when the rule is enabled:

{
 "sort-decorators/sort-on-accessors": [
    "warn",
    {
      "autoFix": false,
      "caseSensitive": true,
      "direction": "asc"
    }
  ]
}

Usage

Usage of "caseSensitive": false

Configuration

{
 "sort-decorators/sort-on-accessors": [
    "warn",
    {
      "caseSensitive": false
    }
  ]
}

❌ Invalid

class MyClass {
  @B @a @c
  public get accessor() { return 0; }
}

✅ Valid

class MyClass {
  @a @B @c
  public get accessor() { return 0; }
}

Usage of "direction": "desc"

Configuration

{
  "sort-decorators/sort-on-accessors": [
    "warn",
    {
      "direction": "desc"
    }
  ]
}

❌ Invalid

class MyClass {
  @A
  @B
  public get accessor() { return 0; }
}

✅ Valid

class MyClass {
  @B
  @A
  public get accessor() { return 0; }
}