gmlewis / flutter-stylizer

Flutter Stylizer is a VSCode extension that organizes your Flutter classes and mixins in an opinionated and consistent manner.
https://marketplace.visualstudio.com/items?itemName=gmlewis-vscode.flutter-stylizer
Apache License 2.0
23 stars 3 forks source link

Is it possible to disable alphabetical sorting ? #29

Open CodingSoot opened 2 years ago

CodingSoot commented 2 years ago

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 commented 2 years ago

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. :joy:

CodingSoot commented 2 years ago

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:

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 commented 2 years ago

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 commented 2 years ago

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.