Skip to content
This repository has been archived by the owner on Dec 4, 2022. It is now read-only.

Is it possible to disable alphabetical sorting ? #29

Open
CodingSoot opened this issue Apr 4, 2022 · 4 comments
Open

Is it possible to disable alphabetical sorting ? #29

CodingSoot opened this issue Apr 4, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@CodingSoot
Copy link

Hello,

I want the extension to group the different class members, constructors... without sorting them alphabetically. It would instead preserve their initial order. Is this possible ?

@gmlewis
Copy link
Owner

gmlewis commented Apr 4, 2022

I suppose that might be possible with a new switch... but I'm a bit hesitant because there are some relatively new options added that ask for sorting... and I'm wondering what the expectation would be if one of those other options (like groupAndSortGetterMethods and sortOtherMethods) were set, but disableSorting (for example) were true.

And if I change the options, then how would backwards compatibility be handled?

I'll leave this issue open for a while before taking action since it is not clear to me how to incorporate this nicely.

Also, it will give a chance for others to comment... let's see how much interest there is in this request.

One other thought is that this thing is supposed to be very opinionated, and now we are thinking of removing its opinions. 😂

@CodingSoot
Copy link
Author

The grouping part is really nice, it's just the sorting within the group that can be inconvenient. For example, if you have named parameters in a certain order, you may want the fields to be declared in the same order. Or you may want to have some methods declared in a certain order because they have some kind of hierarchy.

I think we could add an option disableSorting that would look like this :

"disableSorting": [
      "named-constructors",
      "public-static-variables",
      "public-instance-variables",
      "public-override-variables",
      "private-static-variables",
      "private-instance-variables",
      "public-override-methods",
      "public-other-methods",
      "private-other-methods",
    ],

For backwards compatibility:

  • disableSorting is optional. When provided, it overrides the sorting behavior of both groupAndSortGetterMethods and sortOtherMethods
  • Deprecate groupAndSortGetterMethods and add a new option groupGetterMethods. If both are provided, the new option groupGetterMethods is used.
  • Deprecate sortOtherMethods.

What do you think ?

One other thought is that this thing is supposed to be very opinionated, and now we are thinking of removing its opinions. 😂

Hopefully it will still have opinions about the grouping part 😂

@gmlewis
Copy link
Owner

gmlewis commented Apr 4, 2022

What do you think ?

Overall, this definitely sounds interesting... but there is one remaining slight snag...
The "getter" methods and "other" methods by default are not sorted... which is why someone requested the two new options that you are asking to be deprecated.

It would be nice to come up with a consistent behavior that is customizable without causing too much churn.

My biggest concern is changing the behavior and having someone's entire project suddenly get thousands of lines changed in a PR because the stylizer is now acting differently.

@CodingSoot
Copy link
Author

The "getter" methods and "other" methods by default are not sorted... which is why someone requested the two new options that you are asking to be deprecated.

They still won't be sorted by default. The disableSorting option won't take effect unless it is provided by the user. (It would default to null)

But I understand that the changes could be quite confusing for the users.

@gmlewis gmlewis added the enhancement New feature or request label Dec 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants