Skip to content

Commit

Permalink
feat: 🎸 add git-cz + husky + commitlint
Browse files Browse the repository at this point in the history
add git-cz + husky + commitlint
  • Loading branch information
lgf-136 committed Sep 27, 2022
1 parent a15a34c commit b5b1702
Show file tree
Hide file tree
Showing 11 changed files with 1,381 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {},
}
3 changes: 3 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "git-cz"
}
10 changes: 10 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# npm test
# npx --no-install commitlint --edit "$1"
npx commitlint --edit "${1}"

# npx husky add .husky/commit-msg "npx --no-install commitlint -e $HUSKY_GIT_PARAMS"

# npx --no-install commitlint -e $HUSKY_GIT_PARAMS
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
6 changes: 6 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"./**/*.{ts,js,tsx,jsx,vue}": [
"eslint --fix",
"git add ."
]
}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@

monorepo-templates

## eslint

pnpm install -D -w eslint typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser vue-eslint-parser eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-vue

## stylelint

## git-cz + husky + commitlint

```
pnpm add -D -w git-cz
pnpm add -D -w @commitlint/cli @commitlint/config-conventional commitlint
pnpm add -D -w husky lint-staged
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'
npx husky add .husky/pre-commit "pnpm run lint-staged"
```

## 子模块的添加

添加子模块非常简单,命令如下:
Expand Down
70 changes: 70 additions & 0 deletions changelog.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module.exports = {
disableEmoji: false,
format: '{type}{scope}: {emoji}{subject}',
list: [ 'test', 'feat', 'fix', 'chore', 'docs', 'refactor', 'style', 'ci', 'perf' ],
maxMessageLength: 64,
minMessageLength: 3,
questions: [ 'type', 'scope', 'subject', 'body', 'breaking', 'issues', 'lerna' ],
scopes: [],
types: {
chore: {
description: 'Build process or auxiliary tool changes',
emoji: '🤖',
value: 'chore',
},
ci: {
description: 'CI related changes',
emoji: '🎡',
value: 'ci',
},
docs: {
description: 'Documentation only changes',
emoji: '✏️',
value: 'docs',
},
feat: {
description: 'A new feature',
emoji: '🎸',
value: 'feat',
},
fix: {
description: 'A bug fix',
emoji: '🐛',
value: 'fix',
},
perf: {
description: 'A code change that improves performance',
emoji: '⚡️',
value: 'perf',
},
refactor: {
description: 'A code change that neither fixes a bug or adds a feature',
emoji: '💡',
value: 'refactor',
},
release: {
description: 'Create a release commit',
emoji: '🏹',
value: 'release',
},
style: {
description: 'Markup, white-space, formatting, missing semi-colons...',
emoji: '💄',
value: 'style',
},
test: {
description: 'Adding missing tests',
emoji: '💍',
value: 'test',
},
messages: {
type: 'Select the type of change that you\'re committing:',
customScope: 'Select the scope this component affects:',
subject: 'Write a short, imperative mood description of the change:\n',
body: 'Provide a longer description of the change:\n ',
breaking: 'List any breaking changes:\n',
footer: 'Issues this commit closes, e.g #123:',
confirmCommit: 'The packages that this commit has affected\n',
},
},
};
8 changes: 4 additions & 4 deletions examples/react/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()]
})
plugins: [ react() ],
});
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,30 @@
"pnpm": ">=7"
},
"scripts": {
"prepare": "husky install",
"commit": "git-cz",
"cz": "git-cz",
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue",
"dev:demo1": "cd projects/vite-project && pnpm install && pnpm dev",
"pull": "git pull && cd .vscode && git pull && cd .. && cd config && git pull && cd .."
},
"devDependencies": {
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"commitlint": "^17.1.2",
"eslint": "^8.24.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-vue": "^9.5.1",
"git-cz": "^4.9.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"react": "^18.2.0",
"typescript": "^4.6.4",
"vite": "^3.1.3",
"vue-eslint-parser": "^9.1.0"
}
}
}
Loading

0 comments on commit b5b1702

Please sign in to comment.