visual-studio-code

VSCode aggressively deletes all code after unconditional return (no-unreachable)


Sometimes I have code like this:

function x() {
  func1();
  func2();
  func3();
}

and when I'm debugging I put a return on the third line if I don't want/care about func2/func3:

function x() {
  func1();
  return;
  
  func2();
  func3();
}

On save, VSCode very rudely deletes func2 and func3!!! Yes I know it is unreachable code, but I am only adding that return there temporarily. A yellow underline would be nice. I can't seem to turn it off. Is there any way to turn it off or am I using it wrong? It seems like a really silly and overzealous feature to me.


Solution

  • Finally fixed the issue.

    In settings.json (~/.config/Code/User/settings.json)

    I had:

    "source.fixAll": true,
    

    changing this to

    "source.fixAll.eslint": true,
    

    Stops the editor removing the unreachable code unnecessarily