TSLint - Preventing error: The key is not sorted alphabetically TSLint - Preventing error: The key is not sorted alphabetically reactjs reactjs

TSLint - Preventing error: The key is not sorted alphabetically


The rule failing here seems to be object-literal-sort-keys.

You should be able to disable it in the rules section of your config file by adding:

"object-literal-sort-keys": false

You can find all the tslint rules here.


For anyone coming here who is doing a migration to TypeScript from javascript, or who simply has a mixed codebase of javascript + typescriptm you may to define this rule inside 'jsRules' as well, i.e. to get rid of this error, when you having console statements defined inside javascript (not typescript files).

//tslint.json{  "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],    "rules": {    "object-literal-sort-keys": false //Disable for typescript  },  "jsRules": {    "object-literal-sort-keys": false //Disable for javascript  }}