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 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.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *