Skip to content

Commit ddb1195

Browse files
authored
refactor/PIN-8192: Added husky and commitlint rules (#1506)
* refactor: added husky to branch name * refactor: add pre-commit file * refactor: update pre-commit file * refactor: updated types for branch * feat: added something (PIN-1234) * Revert "feat: added something (PIN-1234)" This reverts commit 9b438b0. * refactor: added commitlint configuration (PIN-8192) * refactor: added type-enum rules (PIN-8192) * docs: added pull request template.MD * fix: added no install on pre-commit * chore: update pull request template * chore: update PR_template.md * fix: update scripts * fix: pre-commit space
1 parent d5a4211 commit ddb1195

File tree

6 files changed

+1015
-25
lines changed

6 files changed

+1015
-25
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## 🔗 Issue
2+
3+
Put here Jira ticket
4+
5+
## 📝 Description / Context
6+
7+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
8+
9+
## 🛠 List of changes
10+
11+
- Feature A
12+
- Feature B
13+
14+
## 🧪 How to test
15+
16+
Describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit "$1"

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
echo "Validate branch name before commit..."
5+
npx --no-install validate-branch-name

commitlint.config.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import type { UserConfig } from '@commitlint/types'
2+
3+
const Configuration: UserConfig = {
4+
extends: ['@commitlint/config-conventional'],
5+
rules: {
6+
'header-max-length': [2, 'always', 200],
7+
'type-enum': [
8+
2,
9+
'always',
10+
[
11+
'feat',
12+
'fix',
13+
'docs',
14+
'chore',
15+
'refactor',
16+
'test',
17+
'style',
18+
'perf',
19+
'ci',
20+
'build',
21+
'revert',
22+
],
23+
],
24+
'header-match-pattern': [2, 'always'],
25+
},
26+
plugins: [
27+
{
28+
rules: {
29+
'header-match-pattern': (parsed) => {
30+
const { header } = parsed
31+
const pattern = /^(feat|fix|docs|chore|refactor|test|style|perf|ci|build|revert): .+$/
32+
33+
if (!header || !pattern.test(header)) {
34+
return [false, 'Message should follow the format: <type>: <description>']
35+
}
36+
37+
return [true]
38+
},
39+
},
40+
},
41+
],
42+
}
43+
44+
export default Configuration

0 commit comments

Comments
 (0)