xgqfrms / learning

learning : A collection of all kinds of resources, videos, pdf, blogs, codes... 📚 + 💻 + ❤
https://learning.xgqfrms.xyz
MIT License
16 stars 12 forks source link

git hooks & husky & eslint #87

Open xgqfrms opened 4 years ago

xgqfrms commented 4 years ago

git hooks & husky & eslint

https://github.com/typicode/husky

https://www.npmjs.com/package/husky

// package.json
{
  "husky": {
    "hooks": {
      "pre-commit": "npm test",
      "pre-push": "npm test",
      "...": "..."
    }
  }
}

{
  "scripts": {
    "build": "rollup -c",
    "watch": "rollup -c --watch",
    "serve": "COOKIE_SECRET=devonly nodemon --watch .data/dist/server .data/dist/server",
    "start": "node ./start.js",
    "watchnserve": "npm run build && (npm run watch & npm run serve)"
  },
"devDependencies": {
    "husky": "4.2.5",
    "lint-staged": "10.2.2",
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.{js,css,md,ts,tsx}": "prettier --write"
  }
}

https://www.cnblogs.com/xgqfrms/p/11650177.html#4569097