Implement Husky for git pre-commit hooks to lint before you commit

This commit is contained in:
kitajchuk
2021-04-29 17:00:52 -07:00
parent 28a922b4bc
commit f37d79bf80
5 changed files with 16 additions and 0 deletions

1
.husky/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
_

4
.husky/pre-commit Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint

View File

@@ -18,6 +18,10 @@ Clone this repository and install [yarn](https://yarnpkg.com/getting-started/ins
- `yarn install`
- Installs node packages
- Installs [husky](https://typicode.github.io/husky/) for git `pre-commit` hooks
- If the `prepare` script doesn't run (issue with yarn v2+) you can run `npx husky install`
- Be warned this code-base is NOT tested with `yarn` v2+ (breaking changes)
- Husky will run `yarn lint` before a git commit and stop the commit if `ESLint` fails
- `yarn dev`
- Serves local dev at [localhost:3000](http://localhost:3000)
- `yarn lint`

View File

@@ -4,6 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"prepare": "husky install",
"dev": "next",
"start": "next start",
"prebuild": "yarn lint",
@@ -15,6 +16,7 @@
"license": "MIT",
"dependencies": {
"classnames": "^2.2.6",
"husky": "^6.0.0",
"nanoid": "^3.1.22",
"next": "^10.0.8-canary.9",
"prismjs": "^1.23.0",

View File

@@ -1287,6 +1287,11 @@ https-browserify@^1.0.0:
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=
husky@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/husky/-/husky-6.0.0.tgz#810f11869adf51604c32ea577edbc377d7f9319e"
integrity sha512-SQS2gDTB7tBN486QSoKPKQItZw97BMOd+Kdb6ghfpBc0yXyzrddI0oDV5MkDAbuB4X2mO3/nj60TRMcYxwzZeQ==
iconv-lite@0.4.24:
version "0.4.24"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"