Skip to content

Commit

Permalink
chore(app): setup commitlint for commit message validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tericcabrel committed Mar 20, 2022
1 parent 0a2ee05 commit 63ab9b8
Show file tree
Hide file tree
Showing 5 changed files with 1,021 additions and 25 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit
16 changes: 16 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const conventionalCommit = require("./conventionalCommit.json");

const typesEnum = Object.keys(conventionalCommit.types);
const scopesEnum = Object.keys(conventionalCommit.scopes);

module.exports = {
extends: ["@commitlint/config-conventional"],
rules: {
"type-enum": [2, "always", typesEnum],
"scope-case": [2, "always", ["camel-case"]],
"scope-enum": [2, "always", scopesEnum],
"subject-empty": [2, "never"],
"subject-case": [2, "always", ["lower-case"]],
"header-max-length": [2, "always", 72],
},
};
53 changes: 53 additions & 0 deletions conventionalCommit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"types": {
"build": {
"description": "Changes which affect CI configuration files and scripts"
},
"chore": {
"description": "Changes which aren't user-facing"
},
"enh": {
"description": "Changes which improve a feature"
},
"docs": {
"description": "Changes which affect documentation"
},
"feat": {
"description": "Changes which introduce a new feature"
},
"fix": {
"description": "Changes which patch a bug"
},
"perf": {
"description": "changes which improve performance."
},
"refactor": {
"description": "Changes which neither fix a bug nor add a feature"
},
"revert": {
"description": "Changes which revert a previous commit"
},
"style": {
"description": "Changes which don't affect code logic, such as white-spaces, formatting, missing semi-colons"
},
"test": {
"description": "Changes which add missing tests or correct existing tests"
}
},
"scopes": {
"api": {},
"app": {},
"auth": {},
"backend": {},
"ci": {},
"cli": {},
"core": {},
"database": {},
"frontend": {},
"lib": {},
"settings": {},
"turbo": {},
"utils": {},
"web": {}
}
}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@
"packages/*",
"apps/*"
],
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"dependencies": {},
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"husky": "^7.0.4",
"prettier": "^2.6.0",
"turbo": "^1.1.6"
},
Expand Down
Loading

0 comments on commit 63ab9b8

Please sign in to comment.