From 3a1518f73dd1c2895e57e9ce6704eff322a7ef1e Mon Sep 17 00:00:00 2001 From: Balaji Sivasakthi <65065614+balaji-sivasakthi@users.noreply.github.com> Date: Wed, 19 Jul 2023 09:44:01 +0530 Subject: [PATCH] chore: deps husky and commitlint --- .commitlintrc.json | 21 +++++++++++++++++++++ .husky/commit-msg | 4 ++++ .husky/pre-commit | 4 ++++ .lintstagedrc | 3 +++ package.json | 8 +++++++- 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .commitlintrc.json create mode 100644 .husky/commit-msg create mode 100644 .husky/pre-commit create mode 100644 .lintstagedrc diff --git a/.commitlintrc.json b/.commitlintrc.json new file mode 100644 index 00000000..51fa6cf9 --- /dev/null +++ b/.commitlintrc.json @@ -0,0 +1,21 @@ +{ + "extends": ["@commitlint/config-conventional"], + "rules": { + "type-enum": [ + 2, + "always", + [ + "ci", + "chore", + "docs", + "feat", + "fix", + "perf", + "refactor", + "revert", + "style", + "assets" + ] + ] + } +} diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 00000000..5e563eba --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx --no-install commitlint --edit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..abf1181c --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged --allow-empty diff --git a/.lintstagedrc b/.lintstagedrc new file mode 100644 index 00000000..6c086480 --- /dev/null +++ b/.lintstagedrc @@ -0,0 +1,3 @@ +{ + "**/*.{js,json}": ["prettier --write"] +} diff --git a/package.json b/package.json index dbb1f221..97edc60c 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "type": "module", "main": "src/index.js", "scripts": { - "start": "nodemon -r dotenv/config src/index.js" + "start": "nodemon -r dotenv/config src/index.js", + "pre-commit": "lint-staged", + "prepare": "husky install" }, "repository": { "type": "git", @@ -51,6 +53,10 @@ "yaml": "^2.3.1" }, "devDependencies": { + "@commitlint/cli": "^17.6.6", + "@commitlint/config-conventional": "^17.6.5", + "husky": "^8.0.0", + "lint-staged": "^13.2.2", "nodemon": "^2.0.22", "prettier": "^3.0.0" }