Skip to main content

Command Palette

Search for a command to run...

Setting auto-formatting of vite vue.js 3 project with VSCode

Published
1 min read
S

I was the main web front-end engineer responsible for developing and maintaining the customer-facing platform for WisdomHall (品學堂) in 2024 Q3 Q4, code reviewed by CTO and a senior engineer. http://learning.wisdomhall.com.tw has total active 257k users, according to their Facebook post: https://www.facebook.com/share/p/1MnjbwZxCV/ My tech stack includes JavaScript, Vue 2, Nuxt 2, git, and Docker.

紀錄一下
ref source: https://vueschool.io/articles/vuejs-tutorials/eslint-and-prettier-with-vite-and-vue-js-3/

  1.  npm init vite@latest
    

    or

  2.  npm create vuetify
    
  3.  npm install --save-dev --save-exact prettier
    
  4.  npm install --save-dev eslint eslint-plugin-vue
    
  5.  npm install eslint-config-prettier --save-dev
    
  6. in .vscode/settings.json

{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "[vue]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

More from this blog

Vue 3 的雞毛蒜皮各種小特性

在 Nuxt 3 專案中,這是一個被稱為「自動導入 (auto-imports)」的特性 我:為何 showPost 不用引用就可以直接使用? [id].vue: 1 lines selecteduseAsyncData Gemini: stat_minus_1Thinking 在 Nuxt 3 專案中,這是一個被稱為「自動導入 (auto-imports)」的特性。 Nuxt 會自動掃描特定目錄下的檔案,例如 composables/ 和 utils/,並將其中定義的函式、變數等在整個應用程...

Sep 25, 20251 min read

請用 10 歲小孩能懂的方式,解釋 Virtual DOM 觀念

當然可以!以下是一個 10 歲小孩也能懂的方式來解釋 Virtual DOM(虛擬 DOM) 是什麼: 🎨 想像你在畫畫一棵樹 你有一張畫紙(這是網頁上的畫面),你正在畫一棵樹 🌳。 有一天你想把樹的葉子從綠色換成黃色,因為是秋天了 🍂。 做法一: 你把整棵樹擦掉,重新畫一棵新的黃色葉子樹。🧽✏️ 這樣很花時間,而且很累對吧? 做法二(更聰明的做法): 你先在一張透明的描圖紙上畫一樣的樹,看看哪裡需要改,發現「只要把葉子塗黃就好!」然後你只改葉子的顏色,其他部分都不動,畫起來又快又省力...

Sep 22, 20252 min read

ChatGPT 用 10 歲孩童能聽懂的方法,解釋 webpage cookies 的原理跟用途

請用十歲孩童能聽懂的方法,解釋網頁 cookie 的原理跟用途 1. Cookie 是什麼? 想像你去一家餅乾店(網站),老闆給你一張小紙條,寫著你的名字和喜好(例如你喜歡巧克力餅乾)。這張小紙條就是「Cookie」。 但它不是可以吃的餅乾,而是電腦裡的一小段文字紀錄,網站會存到你的瀏覽器裡。 2. 它是怎麼運作的? 你第一次到網站 → 網站寫一張小紙條(Cookie)給你。 你下次再來 → 你把小紙條交給老闆(網站)。 老闆一看,就知道: 你是誰 你喜歡什麼 你上次逛到哪一頁 ...

Sep 17, 20251 min read

sunpochin

56 posts