DEV Community

loading...

Vscode Auto Format 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?

Discussion (5)

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
K G 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.

Collapse
dnktin profile image
Forem Open with the Forem app