TSLint - Disable alphabetical ordering of members
Asked Answered
L

1

7

How can I disable alphabetical ordering of members in object literal syntax?

Example:

function receiveLogin(user) {
  return {
    type: LOGIN_SUCCESS,
    isFetching: false,
    isAuthenticated: true,
    id_token: user.id_token,
  };
}

I want to have the type as the first item.

Lisk answered 15/9, 2016 at 13:23 Comment(2)
The property to add to your tslint.json to disable this is right there in the error message.Infelicity
Actually I am wondering why by default it's enabled. Such an annoying rule.Measly
W
15

You should have "object-literal-sort-keys": false in your tslint.json rules.

Example:

{
  "extends": "tslint:latest",
  "rules": {
    "object-literal-sort-keys": false
  }
}
Winny answered 15/9, 2016 at 13:28 Comment(1)
Is there any way to enable/disable this for a single object? I am afraid of possible side effects if I disable it across the entire application.Vitovitoria

© 2022 - 2024 — McMap. All rights reserved.