infctr / eslint-plugin-typescript-sort-keys

A linter plugin to require sorting interface and string enum keys
ISC License
143 stars 25 forks source link

Conflict to @typescript-eslint/member-ordering #30

Open neviaumi opened 3 years ago

neviaumi commented 3 years ago

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 ?

infctr commented 3 years ago

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

davidnghk01 commented 3 years ago

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

infctr commented 3 years ago

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?

davidnghk01 commented 3 years ago

Unfortunately it didn't have autofix feature :(

infctr commented 3 years ago

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

manojdcoder commented 2 years ago

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

nelson6e65 commented 2 years ago

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. 😅

shellscape commented 11 months ago

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