Skip to content

Commit

Permalink
chore: fix husky configuration
Browse files Browse the repository at this point in the history
apprently, husky has recently changed their configuration format, and for that reason our pre-commit hook was never running. The following blog posts explain the change in depth:

* https://blog.typicode.com/husky-git-hooks-javascript-config/
* https://blog.typicode.com/husky-git-hooks-autoinstall/

This commit fixes the husky configuration + upgrades husky to 6.0.0, so
now prettier / eslint should run again before every commit,
automatically.
  • Loading branch information
urish committed May 29, 2021
1 parent 562e802 commit 7f47c56
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"scripts": {
"build": "rimraf dist && tsc && tsc -p tsconfig.esm.json && node build-scripts/dist-package-json",
"prepublish": "npm run build",
"prepare": "husky install",
"lint": "eslint . --ext .ts",
"start": "ts-node demo/emulator-run.ts",
"start:micropython": "ts-node demo/micropython-run.ts",
Expand All @@ -37,7 +38,7 @@
"@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1",
"eslint": "^7.26.0",
"husky": "^5.1.1",
"husky": "^6.0.0",
"jest": "^26.6.3",
"lint-staged": "^11.0.0",
"prettier": "^2.2.1",
Expand All @@ -48,15 +49,10 @@
"typescript": "^4.1.3"
},
"lint-staged": {
"src/**/*.ts": [
"**/*.{js,ts}": [
"eslint --fix",
"prettier --write",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}

0 comments on commit 7f47c56

Please sign in to comment.