typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
109 stars 51 forks source link

Add "Sort Imports" command to vscode extension & lsp #635

Closed camerondubas closed 10 months ago

camerondubas commented 11 months ago

As requested here https://github.com/typed-ember/glint/issues/626, this adds a "Sort Imports" command to the vscode extension and implements a request in the language server to get the TextEdits needed to organize the imports of the current file.

https://github.com/typed-ember/glint/assets/6216460/18df1dbd-670e-476e-ab0c-ce4b3dcb5e4d

ijlee2 commented 11 months ago

How does the Sort Imports command work on a project that already has eslint-plugin-simple-import-sort (this plugin works on *.{gjs,gts} files)? Would there be some conflict between the two?

dfreeman commented 11 months ago

@ijlee2 I imagine it would interact in exactly the same way as that plugin does with the built-in "Sort Imports" commands that are provided for regular JS and TS files today. Presumably if you're using the eslint plugin, then you aren't invoking this command and instead are relying on eslint --fix or fix-on-save instead.

ijlee2 commented 11 months ago

@dfreeman Sounds good, thanks for the clarification.

NullVoxPopuli commented 10 months ago

@camerondubas looks like there are lint failures? Can you address and push? Thanks!

camerondubas commented 10 months ago

Thanks for getting this in!

bartocc commented 10 months ago

Thx for this feature 🙏

We've been using source.organizeImports for a while, and this both sorts, but also removes unused imports. @camerondubas , I know you chose to not implement this feature in this PR, but are there any plans on adding this?

camerondubas commented 10 months ago

@bartocc Ya I could take a look at that. Should have some time over the next week