Skip to content

Commit

Permalink
feat: add commitlint
Browse files Browse the repository at this point in the history
  • Loading branch information
Hub-yang committed Mar 8, 2024
1 parent daac894 commit 39a72fe
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 197 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"

pnpm commitlint ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm lint-staged
20 changes: 20 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', [
'build',
'ci',
'docs',
'feat',
'merge',
'fix',
'perf',
'refactor',
'style',
'test',
'revert',
'update',
'chore',
]],
},
}
6 changes: 5 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import antfu from '@antfu/eslint-config'

export default antfu()
export default antfu({
rules: {
'no-console': 'off',
},
})
20 changes: 17 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"bin": {
"hubyang-commitlint-i": "bin/commitlint-init.mjs",
"hubyang-test": "bin/test.mjs"
"hubyang-commitlint-i": "bin/commitlint-init.mjs"
},
"files": [
"bin",
Expand All @@ -43,16 +42,31 @@
"build": "unbuild",
"release": "bumpp && npm publish",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
"lint:fix": "eslint . --fix",
"prepare": "husky",
"commitlint": "commitlint --edit"
},
"devDependencies": {
"@antfu/eslint-config": "^2.6.4",
"@commitlint/cli": "^19.0.3",
"@commitlint/config-conventional": "^19.0.3",
"@types/node": "^20.11.24",
"bumpp": "^9.4.0",
"eslint": "^8.57.0",
"eslint-plugin-format": "^0.1.0",
"execa": "^8.0.1",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"typescript": "^5.3.3",
"unbuild": "^2.0.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint --edit $1"
}
},
"lint-staged": {
"*": "eslint . --fix"
}
}
Loading

0 comments on commit 39a72fe

Please sign in to comment.