From b2c508487a0685b0303e10cfe1bdbdf85ea37417 Mon Sep 17 00:00:00 2001 From: Amarnath Karthi <97amarnathk@gmail.com> Date: Thu, 7 Oct 2021 22:57:48 +0530 Subject: [PATCH] feat: setup husky for commit lint --- .commitlintrc.json | 6 ++++++ .husky/commit-msg | 4 ++++ .husky/pre-commit | 4 ++++ package.json | 6 +++++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .commitlintrc.json create mode 100755 .husky/commit-msg create mode 100755 .husky/pre-commit diff --git a/.commitlintrc.json b/.commitlintrc.json new file mode 100644 index 00000000..c46786f9 --- /dev/null +++ b/.commitlintrc.json @@ -0,0 +1,6 @@ +{ + "extends": ["@commitlint/config-conventional"], + "rules": { + "type-enum": [2, "always", ["ci", "chore", "docs", "feat", "fix", "perf", "refactor", "revert", "style"]] + } +} \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 00000000..7cd8dd9a --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no-install commitlint --edit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..689d8ff5 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +# npm test diff --git a/package.json b/package.json index 16dc4261..942d8a00 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "eslint:check": "eslint 'src/**'", "infra:stop": "docker-compose --project-directory . -f src/test/db/docker-compose.yml down --remove-orphans", "infra:start": "docker-compose --project-directory . -f src/test/db/docker-compose.yml up -d && sleep 5 && npm run migration:run", - "infra:restart": "npm run infra:stop && npm run infra:start" + "infra:restart": "npm run infra:stop && npm run infra:start", + "prepare": "husky install" }, "author": "Supabase", "license": "ISC", @@ -46,6 +47,8 @@ "under-pressure": "^5.7.0" }, "devDependencies": { + "@commitlint/cli": "^13.2.0", + "@commitlint/config-conventional": "^13.2.0", "@types/busboy": "^0.2.3", "@types/crypto-js": "^4.0.2", "@types/fs-extra": "^9.0.12", @@ -59,6 +62,7 @@ "eslint-config-prettier": "^8.1.0", "eslint-plugin-prettier": "^3.3.1", "form-data": "^4.0.0", + "husky": "^7.0.0", "jest": "^26.6.3", "json-schema-to-ts": "^1.6.0", "pino-pretty": "^4.7.1",