Skip to content

Instantly share code, notes, and snippets.

@msarsha
Created October 18, 2019 13:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msarsha/3bbaaf77680b0d44070306691fa6b198 to your computer and use it in GitHub Desktop.
Save msarsha/3bbaaf77680b0d44070306691fa6b198 to your computer and use it in GitHub Desktop.
Setting up git hooks with husky, commitlint and prettier
  1. npm install prettier --save-dev --save-exact

  2. npx mrm lint-staged

  3. npm install --save-dev @commitlint/{cli,config-conventional}

  4. echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js

  5. edit package.json:

  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }  
  },
  "lint-staged": {
    "apps/**/*.{ts, json, scss, html}": [
      "prettier --write",
      "git add"
    ],
    "libs/**/*.{ts, json, scss, html}": [
      "prettier --write",
      "git add"
    ]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment