Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Sorting #19

Closed
JCKodel opened this issue Oct 4, 2019 · 11 comments
Closed

[Feature Request] Sorting #19

JCKodel opened this issue Oct 4, 2019 · 11 comments
Labels
enhancement New feature or request

Comments

@JCKodel
Copy link

JCKodel commented Oct 4, 2019

It would be nice if, after adding a package, the contents of pubspec.yaml is sorted.
I use https://github.com/Tyriar/vscode-sort-lines to do so, but is an extra step.

@jeroen-meijer
Copy link
Owner

I agree, this would be nice.
Thanks for the suggestion.

@jeroen-meijer jeroen-meijer added the enhancement New feature or request label Mar 30, 2020
@jeroen-meijer
Copy link
Owner

Will implement this in the next version.

I was thinking of keeping the top-level order the same, but to sort all the dependencies and dev_dependencies by name.
Additionally, I want to sort them by order of:

  1. Local packages
  2. Hosted on other hosts (not pub.dev)
  3. Rest (regular dependencies)

All alphabetically.

@JCKodel what do you think?

@JCKodel
Copy link
Author

JCKodel commented Oct 5, 2020

@jeroen-meijer That would be awesome. This separation between git, file and pub.dev is good (and actually is the way I work, using the https://github.com/Tyriar/vscode-sort-lines plugin (this plugin only sort lines, so dependencies such as git has to be done manually))

@jeroen-meijer
Copy link
Owner

Great. Working on this right now. Expect a release later today (2.1.0).

@jeroen-meijer
Copy link
Owner

Implemented. Sorting will now take place like this:

dev_dependencies:
  flutter:
    sdk: "whatever"
  freezed:
    path: ../freezed
  zombies:
    git: https://.../zombies.git
  forrest:
    hosted: abcdef
  animations: 1.1.2
  get_it: 5.0.1

jeroen-meijer added a commit that referenced this issue Oct 5, 2020
- auto sort dependencies after import (implements #19)
- add option for auto sorting
- add command for auto sorting
- fix crash when pubspec or dependencies are empty (fixes #56, #54, #49, #47)
jeroen-meijer added a commit that referenced this issue Oct 5, 2020
- auto sort dependencies after import (implements #19)
- add option for auto sorting
- add command for auto sorting
- fix crash when pubspec or dependencies are empty (fixes #56, #54, #49, #47)
@csells
Copy link

csells commented May 21, 2021

It would be great if sorting worked according to the Dart link rule sort_pub_dependencies. In that case, all of the sorting is based on the name of the dependency, including putting "flutter" in the right place in the sorting order, e.g. the following is how Pubspec Assist does it:

image

However, the following is the sort order required by the lint rule:

image

@jeroen-meijer
Copy link
Owner

Great suggestion @csells! I'll have a look at making this change soon 👍🏻

@tmaihoff
Copy link

tmaihoff commented Jun 7, 2021

Just came here to request the alphabetic sorting as well. Would be nice to have that function implemented.

Keep up the good work 👍

@jeroen-meijer
Copy link
Owner

@csells @tmaihoff @JCKodel This has been implemented in v2.3.0 (19219b1). Closing 😄

@csells
Copy link

csells commented Aug 6, 2021

Yay!

@csells
Copy link

csells commented Aug 6, 2021

And it works perfectly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants