Skip to content

Commit 42a4d21

Browse files
committed
feat: add commit script and commitlint configuration
1 parent 044f201 commit 42a4d21

File tree

8 files changed

+495
-24
lines changed

8 files changed

+495
-24
lines changed

commitlint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['./src/config/commitlint.config'],
3+
}

commitlint.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./dist/config/commitlint.config')

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"build": "node src build",
1616
"lint": "node src lint",
1717
"format": "node src format",
18-
"validate": "node src validate"
18+
"validate": "node src validate",
19+
"commit": "node src commit"
1920
},
2021
"husky": {
2122
"hooks": {
@@ -43,6 +44,8 @@
4344
"@babel/preset-flow": "^7.0.0",
4445
"@babel/preset-react": "^7.0.0",
4546
"@babel/runtime": "^7.5.4",
47+
"@commitlint/config-conventional": "^8.1.0",
48+
"@commitlint/prompt": "^8.1.0",
4649
"@typescript-eslint/eslint-plugin": "^2.1.0",
4750
"arrify": "^2.0.1",
4851
"babel-core": "^7.0.0-0",
@@ -53,6 +56,7 @@
5356
"babel-plugin-transform-inline-environment-variables": "^0.4.0",
5457
"babel-plugin-transform-react-remove-prop-types": "^0.4.21",
5558
"browserslist": "^4.6.4",
59+
"commitizen": "^4.0.3",
5660
"concurrently": "^4.1.1",
5761
"cross-env": "^5.1.4",
5862
"cross-spawn": "^6.0.5",

src/__tests__/__snapshots__/index.js.snap

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Usage: ../ [script] [--flags]
2929
Available Scripts:
3030
build
3131
ci-after-success
32+
commit
3233
format
3334
lint
3435
pre-commit

src/config/commitlint.config.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'type-enum': [
5+
2,
6+
'always',
7+
[
8+
'build',
9+
'chore',
10+
'ci',
11+
'docs',
12+
'feat',
13+
'fix',
14+
'perf',
15+
'refactor',
16+
'revert',
17+
'test',
18+
],
19+
],
20+
'scope-case': [1, 'always', 'kebab-case'],
21+
'scope-enum': [1, 'always', ['deps', 'build']],
22+
},
23+
}

src/config/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
babel: require('./babelrc'),
3+
commitlint: require('./commitlint.config'),
34
eslint: require('./eslintrc'),
45
jest: require('./jest.config'),
56
lintStaged: require('./lintstagedrc'),

src/scripts/commit.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const path = require('path')
2+
const {bootstrap} = require('commitizen/dist/cli/git-cz')
3+
4+
const here = p => path.join(__dirname, p)
5+
6+
bootstrap({
7+
cliPath: here('../../node_modules/commitizen'),
8+
config: {
9+
path: '@commitlint/prompt',
10+
},
11+
})

0 commit comments

Comments
 (0)