Open micthiesen opened 4 months ago
I can get around this by enabling the "source.removeUnusedImports"
code action on format:
But I think there's a race condition between all the code actions that causes the imports to duplicate on save:
@micthiesen did you find any solution to the duplicated imports problem?
@micthiesen did you find any solution to the duplicated imports problem?
No I'm back to VSCode 😭
Having the exact same problem and it is making me want to go back to vscode 😭 EDIT: now it started working, but it is adding eslint disable every time it needs to format, terrible experience
{
"theme": "Ayu Mirage",
"ui_font_size": 13,
"buffer_font_size": 13,
"format_on_save": "on",
"languages": {
"TypeScript": {
"code_actions_on_format": {
"source.fixAll.eslint": true,
"source.organizeImports": true,
"source.removeUnusedImports": true
}
},
"TSX": {
"code_actions_on_format": {
"source.fixAll.eslint": true,
"source.organizeImports": true,
"source.removeUnusedImports": true
}
}
},
"formatter": {
"code_actions": {
"source.fixAll.eslint": true,
"source.organizeImports": true,
"source.removeUnusedImports": true
}
}
}
For me just this works as a local .zed/settings.json
in a react/tsx project:
{
"format_on_save": "on",
"code_actions_on_format": {
"source.removeUnusedImports": true,
"source.addMissingImports": true,
"source.fixAll.eslint": true,
"sourceAll.organizeImports": true
}
}
EDIT: Nevermind this adds e.g. // eslint-disable-next-line react/jsx-no-undef
on Zed Preview 0.145.1
The comments added might be related to this It should be fixed in the tomorrow preview release
Any updates on this? I am trying to make the switch to zed but this is kind of a deal breaker.
Check for existing issues
Describe the bug / provide steps to reproduce it
The code action
"source.organizeImports"
is supposed to both sort imports and also remove unused imports. Compared to the"source.sortImports"
code action which only sorts imports. See here.To reproduce, create a TS file and import something that isn't used. Select "Organize Imports". The unused import is not removed.
Environment
Zed: v0.132.2 (Zed) OS: macOS 14.1.2 Memory: 32 GiB Architecture: aarch64
Also:
"typescript": "^5.3.3"
If applicable, add mockups / screenshots to help explain present your vision of the feature
When chosen from the context menu, "Organize Imports" successfully sorts imports but it doesn't remove unused imports:
It also only sorts when used as a
"code_actions_on_format"
option:If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.No response