How can I prevent VS Code to revert my changes on save?

Viewed 2634

I have a file open in VS Code

enter image description here

As you can see on line 1, 5, and 6, there are errors.

When I hovered over them, I saw this message.

enter image description here

Then, I decided to fix them base on the error message suggested.

enter image description here

Now, the 3 errors are gone. BUT as soon as I hit save.

Those errors are coming back. My changes seem to be reverted.


I have this set in my settings.json

"editor.formatOnSave": true

Any suggestions on how can I prevent this behavior?

2 Answers

I wouldn't change either editor.formatOnSave to false nor disable tslint as the other answers suggest. They are both very good tools to use. Although you might consider switching from tslint to eslint, as ts-lint will be deprecated.

Your problem is actually that tslint wants to use single quotes and your VSCode is configured to use double quotes. So when you format your code automatically, VSCode will use double quotes. You can change this with this simple setting in settings.json:

"typescript.preferences.quoteStyle": "single",

Disable Angular essential extension or disable tslint extension.

disable angularessentials

Related