[Tool] Enable Prettier in VSCode as Format on Save and add config files to gitingore

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

 

Also you might want to make sure Prettier use eslint rules as well, not just ingore eslint rules we already setup:

install:

npm install --save-dev eslint-config-prettier
// .eslintrc

{
  "extends": ["eslint:recommended", "prettier"]
}

 

 

 

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

 

posted @ 2019-04-16 19:31  Zhentiw  阅读(259)  评论(0编辑  收藏  举报