Skip to content

Commit a852792

Browse files
author
Evgeny Zakharov
committed
feat(repo): add cz and pre-commit hooks
1 parent 5e29ba9 commit a852792

File tree

9 files changed

+1398
-44
lines changed

9 files changed

+1398
-44
lines changed

.cz-config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
types: [
3+
{ name: "🎸 feat: A new feature", value: "feat" },
4+
{ name: "🐛 fix: A bug fix", value: "fix" },
5+
{ name: "🕯 wip: Work in progress", value: "wip" },
6+
{ name: "🤖 chore: Build process or auxiliary tool change", value: "chore" },
7+
{ name: "💡 refactor: A code change that neither fixes a bug or adds a feature", value: "refactor" },
8+
{ name: "💄 style: Markup, white-space, formatting, missing semi-colons...", value: "style" },
9+
{ name: "💍 test: Adding missing tests", value: "test" },
10+
{ name: "💪 perf: A code change that improves performance", value: "perf" },
11+
{ name: "✏️ docs: Documentation only changes", value: "docs" },
12+
{ name: "🕹️ ci: CI related changes", value: "ci" },
13+
{ name: "🔥 revert: Revert to a commit", value: "revert" },
14+
],
15+
allowCustomScopes: true,
16+
skipQuestions: ["footer"],
17+
allowBreakingChanges: ["feat", "fix", "revert", "refactor"],
18+
}

.czrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"path": "node_modules/cz-customizable"
3+
}

.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+
yarn commitlint --edit $1

.husky/pre-commit

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+
yarn lint-staged

.lintstagedrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"*.{js,jsx,ts,tsx}": [
3+
"eslint --fix"
4+
],
5+
"*.{md,json}": [
6+
"prettier --write"
7+
]
8+
}

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Then, the `release` workflow handles everything:
8080
### Regular flow
8181

8282
1. Create [feature branch](#conventions)
83-
2. Make changes in your feature branch and [commit](#conventions)
83+
2. Make changes in your feature branch and [commit](#conventions) using `yarn commit`
8484
3. Create a Pull Request from your feature branch to `main`
8585
The PR is needed to test the code before pushing to release branch
8686
4. If your PR contains breaking changes, don't forget to put a `BREAKING CHANGES` label
@@ -92,24 +92,28 @@ Then, the `release` workflow handles everything:
9292
1. Assume your prerelease tag is `beta`
9393
2. Create `release/beta` branch
9494
3. Create [feature branch](#conventions)
95-
4. Make changes in your feature branch and [commit](#conventions)
95+
4. Make changes in your feature branch and [commit](#conventions) using `yarn commit`
9696
5. Create a Pull Request from your feature branch to `release/beta`
9797
The PR is needed to test the code before pushing to release branch
9898
6. Create Github release with tag like `v1.0.0-beta`, pointing to `release/beta` branch
99-
For next `beta` versions use semver build syntax: `v1.0.0-beta+1`
99+
For next `beta` versions use semver build syntax: `v1.0.0-beta+1`
100100
7. After that, the `release` workflow will publish your package with the `beta` tag
101101
8. When the `beta` version is ready to become `latest` - create a Pull Request from `release/beta` to `main` branch
102102
9. Continue from the [Regular flow's](#regular-flow) #5 step
103103

104104
### Conventions
105105

106106
**Feature branches**:
107+
107108
- Should start with `feat/`, `fix/`, `docs/`, `refactor/`, and etc., depending on the changes you want to propose (see [pr-labeler.yml](./.github/pr-labeler.yml) for a full list of scopes)
108109

109110
**Commits**:
111+
112+
- Should be created using `yarn commit` command
110113
- Should follow the [Conventional Commits specification](https://www.conventionalcommits.org)
111114

112115
**Pull requests**:
116+
113117
- Should have human-readable name, for example: "Add a TODO list feature"
114118
- Should describe changes
115119
- Should have correct labels
@@ -148,4 +152,4 @@ Then, the `release` workflow handles everything:
148152

149153
### The last step
150154

151-
Remove **Using Template** section from README (don't forget about Navigation links)
155+
Remove **Using Template** section from README (don't forget about Navigation links)

commitlint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['cz'],
3+
}

package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,30 @@
2121
"test": "jest",
2222
"test:watch": "yarn test --watchAll",
2323
"lint": "eslint --ext .ts,.tsx src",
24-
"lint:fix": "yarn lint --fix"
24+
"lint:fix": "yarn lint --fix",
25+
"commit": "cz",
26+
"prepare": "is-ci || husky install",
27+
"postinstall": "yarn prepare",
28+
"prepack": "pinst --disable",
29+
"postpack": "pinst --enable"
2530
},
2631
"dependencies": {},
2732
"devDependencies": {
33+
"@commitlint/cli": "^17.0.2",
2834
"@rollup/plugin-typescript": "^8.3.2",
2935
"@types/jest": "^27.5.1",
36+
"commitizen": "^4.2.4",
37+
"commitlint-config-cz": "^0.13.3",
38+
"cz-customizable": "^6.3.0",
3039
"esbuild": "^0.14.39",
3140
"eslint": "^8.16.0",
32-
"eslint-kit": "^5.1.4",
41+
"eslint-kit": "^5.2.1",
42+
"husky": "^8.0.1",
43+
"is-ci": "^3.0.1",
3344
"jest": "^28.1.0",
3445
"jest-serializer-path": "^0.1.15",
46+
"lint-staged": "^13.0.0",
47+
"pinst": "^3.0.0",
3548
"rollup": "^2.73.0",
3649
"rollup-plugin-bundle-size": "^1.0.3",
3750
"rollup-plugin-dts": "^4.2.1",

0 commit comments

Comments
 (0)