Setup Prettier

Prettier

npm install --save-dev prettier

建主一個 .prettierrc.js 檔案來做 prettier 的設定

之後便可以加入適合自己的config

module.exports = {
  trailingComma: 'all',
  tabWidth: 2,
  semi: true,
  singleQuote: true,
};

package.json 加入以下設定

"scripts": {
    "format": "prettier check .",
    "fix-format": "prettier --write ."
  },

format 用來檢查有沒有什麼檔案需要再format

fix-format 是用prettier 去format 所有檔案

hope you find it useful

Chi Yau
Chi Yau
Software Engineer

Interested on Learning new stuff and experience sharing