Closed nirtamir2 closed 3 months ago
I created a new ESLint plugin for it eslint-plugin-sort-destructure-keys-typescript
@nirtamir2 related to eslint-plugin-sort-destructure-keys-typescript - does it supported nested destructuring ? will order of destructured keys be enforced when destructuring multiple levels ? const {a: {b: {d, c}}} = e;
should be identified as an issue if the type for nested b property of type a - has properties defined as c and d - in this order
Hi @gabriel-calin-lazar, Thank you for your comment. At this time, only two days after creating the plugin, this feature is not yet supported. However, it would be a valuable addition, so I opened an issue at https://github.com/nirtamir2/eslint-plugin-sort-destructure-keys-typescript/issues/3.
@nirtamir2 is there something similar for the opposite - to enforce ordering of properties when one defines an object literal with a type in place ? to enforce that property ordering in literal definition matches the ordering of the properties from the type or interface. basically a mirror of this eslint plugin - not for destructuring but for object construction
@gabriel-calin-lazar why would you want to do it? Also, assume that the type can include more properties than the destructuring / you won't have control changing it (for example - type that comes from 3rd party lib).
Hi I would like the option to use the TypeScript type properties order to sort destructure keys. It should be using @typesccript-eslint
The option can be called
{matchTypeScriptTypePropertiesOrder: true}
and we can make it non strict - so for A&B stuff that are not simple we won't force it. It may be a big change so maybe it's better to create a new plugineslint-plugin-sort-destructure-keys-typescript