diff --git a/.eslintrc b/.eslintrc index 6bfb577..5e40e19 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,9 @@ { - "ignorePatterns": ["dist", "typechain"], + "ignorePatterns": [ + "dist", + "node_modules", + "typechain" + ], "root": true, "parser": "@typescript-eslint/parser", "plugins": [ @@ -15,6 +19,6 @@ "rules": { "no-console": 2, "prettier/prettier": 2, - "strict" : 2 + "strict": 2 } } \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..36af219 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged diff --git a/.prettierignore b/.prettierignore index c4581c3..b212f0e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ # Ignore artifacts: +node_modules dist typechain \ No newline at end of file diff --git a/README.md b/README.md index a45cff0..224c71d 100644 --- a/README.md +++ b/README.md @@ -81,3 +81,10 @@ npm run build npm run test ``` +#### Husky Git Commit Hooks +To enable Husky commit hooks to trigger the lint-staged behaviour of formatting and linting the staged files prior +before committing, prepare your repo with `prepare`. + +```shell +npm run prepare +``` \ No newline at end of file diff --git a/package.json b/package.json index 7c2170c..b09c3bb 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,9 @@ "scripts": { "build": "hardhat compile", "clean": "hardhat clean", - "lint": "eslint . --ext .ts", "format": "prettier ./**/*.ts --write", + "lint": "eslint . --ext .ts", + "prepare": "husky install", "test": "mocha --exit --recursive --require ts-node/register 'test/**/*.test.ts'" }, "devDependencies": { @@ -48,15 +49,10 @@ "dependencies": { "bunyan": "^1.8.15" }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } - }, "lint-staged": { "*.ts": [ - "eslint --cache --fix", - "prettier --write" + "npm run format", + "npm run lint --fix" ] } }