Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Stop using object-literal-sort-keys #2583

Closed
andy-hanson opened this issue Apr 16, 2017 · 10 comments
Closed

Stop using object-literal-sort-keys #2583

andy-hanson opened this issue Apr 16, 2017 · 10 comments

Comments

@andy-hanson
Copy link
Contributor

This rule is disabled in 133 files! Wouldn't it be easier to just disable it in the config?

@dgreene1
Copy link

omg please remove this. I can't even get the disabling to work well in vscode. To me, the ordering of imports is personal and up to the dev.

@vajahath
Copy link

I would suggest to add a --fixer for this.
it would sort it as needed..
well ordered sorted keys in the code looks awesome 🏟️ and clean.

@breathe
Copy link

breathe commented Jul 30, 2017

I can't imagine anyone wanting this rule turned on without an auto-fix for it ...? Would a feature-request bug to create the auto-fix for object-literal-sort-keys be helpful?

@adidahiya
Copy link
Contributor

adidahiya commented Jul 31, 2017

We generally accept auto-fixer contributions for all rules, so a separate Github issue tracking it is not necessary.

Note that this original ticket was filed to track the enabling of object-literal-sort-keys in this source repo, not in distributions of the TSLint library.

@serhiipalash
Copy link

We generally accept auto-fixer contributions for all rules

Auto-fixer for object-literal-sort-keys could produce very hard to debug errors. Read this prettier/prettier#1096

@tharakawj
Copy link

I personally don't like this rule because sometimes it's not intuitive to write keys in alphabetical order. As an example if there is a schedule object,
{ start: '', end: '', frequency: '' }
order make more sense to me than
{ end: '', frequency: '', start: '' }.
I know it's a personal preference and that's the whole point to remove this rule from recommended preset.

@pronebird
Copy link

pronebird commented Jun 24, 2018

Is there any way to turn that... "feature" off?

update: just found that adding "object-literal-sort-keys": false to rules section of tslint.json disables this feature 🎉

@mlg87
Copy link

mlg87 commented Aug 1, 2018

any idea why this config would still have the rule applying and preventing me from compiling?

{
  "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
  "linterOptions": {
    "exclude": ["config/**/*.js", "node_modules/**/*.ts"]
  },
  "rules": {
    "object-literal-sort-keys": false,
    "no-console": false
  },
  "jsRules": {
    "object-literal-sort-keys": false
  }
}

@cjduncana
Copy link

I personally don't like this rule because sometimes it's not intuitive to write keys in alphabetical order. As an example if there is a schedule object,
{ start: '', end: '', frequency: '' }
order make more sense to me than
{ end: '', frequency: '', start: '' }.
I know it's a personal preference and that's the whole point to remove this rule from recommended preset.

The rationale behind match-declaration-order is to implement this order.

@JoshuaKGoldberg
Copy link
Contributor

The discussion here has gotten a little off topic 😊 closing for housekeeping purposes.

tl;dr:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests