Node JS
  • SetUp Node&NVM
  • Folder Structure
  • Setup NodeJS Project
  • Library
    • Awilix
    • Swagger
    • Express
    • Jest
      • Supertest
    • Prettier
    • Eslint & Tslint
      • Tslint & Prettier
      • Tslint Plugin Prettier
      • Config With Airbnb
    • Husky And Friends
    • Sentry
  • INFRASTRUCTURE
    • Docker
      • Docker image
      • Docker container
      • Docker Volume
      • Docker command
      • Docker Compose
      • Problem & Solution
    • SonarQube
      • How to use in Nodejs
    • NGinX
    • ดูเพิ่มเติม
  • Note
    • .env declare type
    • Learn Link
Powered by GitBook
On this page
  • install
  • Prettier setting
  • Ingore file
  • ทำให้ Fotmat ทุกครั้งเมื่อ Save
  1. Library

Prettier

Code Formatter ซึ่งช่วยให้คุณสามารถจัดรูปแบบ Code ให้ดูเป็นระเบียบสวยงามยิ่งขึ้น

install

โดยที่ใช้ config ของ eslint airbnb แต่จะปิดการทำงานส่วน eslint ไป

npm install --save-dev prettier
touch .prettierrc
touch .prettierignore

Prettier setting

#.prettierrc
{
  "printWidth": 100,
  "singleQuote": true
}

Ingore file

#.prettierignore
build
coverage

ทำให้ Fotmat ทุกครั้งเมื่อ Save

#vscode/settings.json:
{
  "editor.formatOnSave": true
}

ถ้าลง Prettier ใน VsCode แล้วทำการแก้ไข .prettierrc ต้อง ปิด-เปิดใหม่ เพื่อให้มัน sync กัน

PreviousSupertestNextEslint & Tslint

Last updated 3 years ago