.vscode/settings.json ตั้ง config แยกต่อ project
settings บาง project-specific ควรอยู่ใน .vscode/settings.json ไม่ใช่ global — commit ไว้ใน repo ได้เลย
เคยเปิด project แล้วต้องเปลี่ยน settings ด้วยมือทุกครั้ง? .vscode/settings.json แก้ได้:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"typescript.tsdk": "node_modules/typescript/lib",
"css.validate": false,
"files.associations": {
"*.astro": "astro"
}
}
ข้อดี:
- ทุกคนใน team ได้ settings เดียวกันโดยไม่ต้อง configure เอง
typescript.tsdkควรตั้งต่อ project เสมอ — ให้ใช้ TypeScript version จากnode_modulesแทน VS Code built-incss.validate: falseปิด warning เมื่อใช้ CSS-in-JS หรือ framework ที่มี custom syntax
โดยทั่วไปควร commit .vscode/settings.json แต่ใส่ .vscode/ ใน .gitignore ถ้าเป็น personal config ที่ไม่ต้องการแชร์