First of all, install Prettier extension: "Pettier - Code formatter".
The open the VSCode setting:
cmd + ,
Search for "format": and enable "Format On Save"
Add .prettierrc file:
{ "tabWidth": 4, "semi": true, "singleQuote": true }
Add .prettierignore file:
dist package-lock.json
Add both file into global gitignore:
touch ~/.gitignore_global // create one if you don‘t have it vim ~/.gitignore_global // edit it //add .prettierrc .prettierignore // Run git config --global core.excludesfile ~/.gitignore_global
[Tool] Enable Prettier in VSCode as Format on Save and add config files to gitingore
原文:https://www.cnblogs.com/Answer1215/p/10719286.html