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

cue/format: sort imports #3701

Open
mezuzza opened this issue Jan 26, 2025 · 1 comment
Open

cue/format: sort imports #3701

mezuzza opened this issue Jan 26, 2025 · 1 comment
Labels
FeatureRequest New feature or request

Comments

@mezuzza
Copy link

mezuzza commented Jan 26, 2025

Currently, cue fmt doesn't seem to build out a canonical ordering for imports. It makes it slightly annoying to look at the top of a file with a number of imports to see what is being used.

As far as I can tell, the ordering of the imports within the import statement has no bearing on the evaluated result, so it seems like this would be a nice way to increase the consistency of the experience.

Prior art here:
Javascript ecosystem uses prettier which doesn't sort imports but javascript has side effects on import
Similar issue with python and black.

Both support other tools (import sort plugin and isort respectively) which handle import sorting and grouping for you.

Go has go fmt which doesn't handle imports, but also supports goimports.

Clang-format supports sorting with options.

@mezuzza mezuzza added FeatureRequest New feature or request Triage Requires triage/attention labels Jan 26, 2025
@mvdan
Copy link
Member

mvdan commented Jan 29, 2025

I agree this is a good idea, and in fact we have some code for it but it's currently unused.

@mvdan mvdan removed the Triage Requires triage/attention label Jan 29, 2025
@mvdan mvdan changed the title Sort imports with cue fmt cue/format: sort imports Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants