Skip to content

Commit

Permalink
chore: add lefthook and commitlint config
Browse files Browse the repository at this point in the history
  • Loading branch information
prgres committed Jul 1, 2024
1 parent 4638664 commit 03e8ec7
Show file tree
Hide file tree
Showing 5 changed files with 1,182 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ cache/**
!cache/.gitkeep
config.yaml
bin/**
node_modules
105 changes: 105 additions & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import type { UserConfig } from "@commitlint/types";
import { RuleConfigSeverity } from "@commitlint/types";

const Configuration: UserConfig = {
extends: ["@commitlint/config-conventional"],
formatter: "@commitlint/format",
rules: {
"header-max-length": [
RuleConfigSeverity.Error,
"always",
Infinity,
] as const,
"body-max-length": [RuleConfigSeverity.Error, "always", Infinity] as const,
"body-max-line-length": [
RuleConfigSeverity.Error,
"always",
Infinity,
] as const,
"type-enum": [
RuleConfigSeverity.Error,
"always",
[
"feat",
"fix",
"perf",
"revert",
"docs",
"chore",
"ref",
"test",
"ci",
"deps",
"build",
],
],
},
prompt: {
questions: {
type: {
description: "Select the type of change that you're committing",
enum: {
feat: {
description: "A new feature",
title: "Features",
emoji: "🆕",
},
fix: {
description: "A bug fix",
title: "Bug Fixes",
emoji: "🪲",
},
perf: {
description: "A code change that improves performance",
title: "Performance Improvements",
emoji: "🚀",
},
revert: {
description: "Reverts a previous commit",
title: "Reverts",
emoji: "⏪",
},
docs: {
description: "Documentation only changes",
title: "Documentation",
emoji: "📑",
},
chore: {
description: "Other changes that don't modify src or test files",
title: "Chores",
emoji: "⚓",
},
ref: {
description:
"A code change that neither fixes a bug nor adds a feature",
title: "Code Refactoring",
emoji: "🧹",
},
test: {
description: "Adding missing tests or correcting existing tests",
title: "Tests",
emoji: "⌛",
},
ci: {
description:
"Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)",
title: "Continuous Integrations",
emoji: "♾️",
},
deps: {
description: "Dependencies",
title: "Dependencies",
emoji: "🛠️",
},
build: {
description: "Build",
title: "Build",
emoji: "🏗️",
},
},
},
},
},
};

export default Configuration;
14 changes: 14 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pre-push:
commands:
backend-lint:
root: backend/
tags: backend
glob: "*.go"
run: golangci-lint run

commitlint:
tags: commandlint
run: |
_HEAD=$(git rev-parse HEAD)
_COMMITS=$(git rev-list --count HEAD ^main)
npx commitlint --from "${_HEAD}"~"${_COMMITS}" --to "${_HEAD}"
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "module",
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"lefthook": "^1.6.15"
}
}
Loading

0 comments on commit 03e8ec7

Please sign in to comment.