基本使用
- 使用npm install prettier --save-dev為您的項目添加更漂亮或全局安裝
- 使用Prettier選擇要格式化的代碼或文件
- 使用“Reformat with Prettier”操作(在MacOS上使用Alt-Shift-Cmd-P或在Windows和Linux上使用Alt-Shift-Ctrl-P)或使用“查找操作”彈出窗口(Cmd / Ctrl-Shift-A)
插件適用編輯器
參考文檔:http://plugins.jetbrains.com/plugin/10456-prettier
code自動格式化:https://prettier.io/docs/en/webstorm.html#running-prettier-on-save-using-file-watcher
自動格式化個人demo:將scope設置為currentFile,免去並行開發其他項目被格式化的問題。