DEV Community

dnkt
dnkt

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)

Collapse
 
dnktin profile image
dnkt

May be I get the point
dev.to/ferasdawod/setting-up-eslin...

Collapse
 
amorpheuz profile image
Yash Dave

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.

Collapse
 
hbwebdev profile image
hb-webdev

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

Collapse
 
kgprajwal profile image
Prajwal

Please install these extensions on your vscode:

Collapse
 
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.