Posts

Install Prettier

  First, install Prettier locally: npm yarn npm install --save-dev --save-exact prettier Then, create an empty config file to let editors and other tools know you are using Prettier: echo {}> .prettierrc.json Next, create a  .prettierignore  file to let the Prettier CLI and editors know which files to  not  format. Here’s an example: # Ignore artifacts: build coverage Tip! Base your .prettierignore on .gitignore and .eslintignore (if you have one). Another tip! If your project isn’t ready to format, say, HTML files yet, add  *.html . Now, format all files with Prettier: npm yarn npx prettier --write . What is that  npx  thing?  npx  ships with  npm  and lets you run locally installed tools. We’ll leave off the  npx  part for brevity throughout the rest of this file! Note: If you forget to install Prettier first,  npx  will temporarily download the latest version. That’s not a good idea when using Pretti...

Sử dụng Prettier với VSCode

 Cài đặt trong project npm install --save-dev --save-exact prettier Tạo file .prettierrc và .prettierignore Cài đặt prettier plugin cho VS code Ctrl+p gõ  ext install esbenp.prettier-vscode  để mở ra cửa sổ cài prettier-vscode Sau khi cài xong Ctrl+p gõ >Prefefences:setting rồi chọn open settings (JSON) và lưu nội dung sau đây { "editor.defaultFormatter" : "esbenp.prettier-vscode" , "[typescript]" : { "editor.defaultFormatter" : "esbenp.prettier-vscode" }, "editor.formatOnSave" : true }

Prettier