Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is vscode formatting my code twice upon saving?

Tags:

eslint

I have my editor set to fix all issues upon saving. However, once I saved, it formats the code to fix the issues, then a split second later reverts back to the original unfixed and unformatted code. This started happening after I updated vscode.

like image 669
Lee Avatar asked Jun 12 '26 22:06

Lee


1 Answers

Not saying this will be your case, but worth checking:

  1. Make sure this setting is false: "editor.formatOnSave": false
  2. Add this to the settings.json file :
"editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },

If you don't use ESLint / Prettier installed, then do the opposite, meaning just make sure that formatOnSave is set to true and you don't have other formatters enabled.

like image 162
Jonathan Perry Avatar answered Jun 15 '26 10:06

Jonathan Perry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!