Node.js - Package - Lint-staged
Quick Chat
lint-staged 可以只對 git staged 的檔案執行 lint 檢查,進而提升檢查效率。
Guide
值得注意的是跟 Prettier 搭配使用,必須確保 ESLint 在 Prettier 前面先執行。
Install
npm install --save-dev lint-staged
Configuration - package.json
{
"scripts": {
...
},
"lint-staged": {
"*.{ts,js}": [
"eslint"
]
}
}
Configuration - .husky/pre-commit
npx lint-staged