DEV Community


Posted on

Vscode Auto Format How to auto format code on vscode

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?

Top comments (5)

dnktin profile image

May be I get the point

amorpheuz profile image
Yash Dave

There is a setting available in ESLint extension for that! Open this 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.

hbwebdev profile image

I apparently forgot I was using lint--I was tearing my hair out trying to get formatting shortcuts to work! Thx

kgprajwal profile image

Please install these extensions on your vscode:

fayaz profile image
Fayaz Ahmed

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.