DEV Community

Cover image for Having trouble😫 with VS code💻 formatOnSave lately?
kapeel kokane
kapeel kokane

Posted on

Having trouble😫 with VS code💻 formatOnSave lately?

If you are like me, then you like your tools.

One of the most important tools in a coder's workflow is automation & I really like automating repetitive tasks like code formatting & linting.

With the availability of extensions like eslint for VS code, setting it up is as simple as installing the extension and maintaining a .eslintrc.js file in the repo.

But lately, I have been facing some issues with the formatOnSave in VS code. My code seemed to behave weird like it was getting formatted and getting un-formatted on every save:

Alt Text

I had to do some research around it and got to the bottom of it. It was related to this settings migration by VS code: https://github.com/microsoft/vscode-eslint#settings-migration

The solution to fix it was simple:
Alt Text

From the vs code settings (which you can open by doing cmd+, or opening settings.json), remove the line number 88 and add line numbers 89-92. Doing that will successfully migrate you to the new settings.

Hope that saved you from an afternoon of headache.

Cheers!

Top comments (1)

Collapse
 
devanghingu profile image
Devang Hingu • Edited

Actually you are missing which settings.json.

VScode have two settings.json file in preference. 1st in USER-TABS and 2nd in WORKSPACE-TABS.
you must have to mention that over there. Otherwise it will not work if it replaced in wrong file.