Skip to content

VSCode deleting my code

VSCode has been automatically deleting unreachable code for me. Seems like that’d be nice, but it really isn’t most of the time. I often want to deliberately make code unreachable while in the middle of development so that I can test a specific branch. When I go to do that and VS Code deletes half...

Murphy R
Jul 24, 20231 min read
1

SCode has been automatically deleting unreachable code for me. Seems like that’d be nice, but it really isn’t most of the time. I often want to deliberately make code unreachable while in the middle of development so that I can test a specific branch. When I go to do that and VS Code deletes half of my file, I’m not thrilled.

This was happening because I had the setting:

{ "editor.codeActionsOnSave": { "source.fixAll": true } }

I’m not sure whether prettier, or typescript was the one telling VSCode to drop stuff, but either way, I’ve fixed my problem by changing my settings as follows:

"editor.codeActionsOnSave": { "source.fixAll": false, "source.fixAll.eslint": true },

Then I still get some auto-fixing of problems, but my deliberately dead code stays around.

Did you enjoy this article?

Recommend it — Standard Reader surfaces well-loved writing to more readers across the network.

Across the AtmosphereDiscussions