eslint-plugin-typescript-sort-keys icon indicating copy to clipboard operation
eslint-plugin-typescript-sort-keys copied to clipboard

Conflict to @typescript-eslint/member-ordering

Open neviaumi opened this issue 3 years ago • 8 comments

I like this plugin idea which will auto-fix the member ordering inside interface

but seem it would conflict to member-order

because this plugin don't care the member type

E.G. given below interface

interface Demo {
   b: string
   a() : void
}

it would complain error in above interface because a is after b.

But if fix it by move a before b, member-ordering would complain method should after attribute.

Beside turn off either one, did it any suggestion can keep both running ?

neviaumi avatar Apr 25 '21 08:04 neviaumi

Yes, seems this would require signature type aware order sorting and/or allow the rule leverage @typescript-eslint/member-ordering

infctr avatar Apr 26 '21 08:04 infctr

Any hints on how should i did the code change ? i can help for open PR for that

davidnghk01 avatar Apr 26 '21 09:04 davidnghk01

Doesn't this do the work https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-ordering.md#sorting-alphabetically-within-member-groups?

infctr avatar Apr 26 '21 09:04 infctr

Unfortunately it didn't have autofix feature :(

davidnghk01 avatar Apr 26 '21 09:04 davidnghk01

I see. Well interface member type signature could be extracted from the node. Then the rule should accept an array of types as options that are going to be used for sorting just the way member-ordering does so that they're fully compatible, however I assume this is going to be a huge effort

infctr avatar Apr 26 '21 09:04 infctr

Would be nice to have this resolved, facing the same issue.

manojdcoder avatar Nov 09 '21 13:11 manojdcoder

There is a way to ignore methods and only sort keys?

In the meantime, a workaround is to move all methods to a separated interface and extend it, so they are sorted separately. 😅

nelson6e65 avatar Jun 01 '22 01:06 nelson6e65

@infctr seems like @nelson6e65 landed on the right fix here. what's the chance of getting this fixed?

shellscape avatar Jul 12 '23 21:07 shellscape