How to auto format code on vscode

dnktin profile image dnkt ・1 min read

I work with vue project that add a eslint file to define some rules. And I also use vscode extension to format the code when pressing alt + shift + f.
I want the formatted code followed the rule that defined in the eslint file of the project.
How can I do that?


markdown guide

There is a setting available in ESLint extension for that! Open this marketplace.visualstudio.com/items... and look for eslint.format.enable under the Settings Options. If you set ESlint as the default formatter, it should be the one formatting your code on Shift + Alt + F.


Please install these extensions on your vscode:


You can use prettier but it'll conflict with vetur formatting. I wanted to do the same thing, but it's just not worth it, with larger projects having eslints with popular configs like airbnb, a lot of issues arise, I had set it up on my work machine and it used to throw hundreds of errors, removed it at the end.