Skip to content

Commit 7747c11

Browse files
authored
feat: setup git pre-commit hooks to run yarn:fix and check commit message (#16)
* feat: apply `eslint` and `prettier` on changed files before commit * feat: add commit message linting based on https://conventionalcommits.org/ * feat: run test on changed files if they presented
1 parent 758c6d4 commit 7747c11

File tree

7 files changed

+535
-19
lines changed

7 files changed

+535
-19
lines changed

Diff for: .husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

Diff for: .husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn commitlint --edit $1

Diff for: .husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn lint-staged

Diff for: .lintstagedrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"*.(js|ts|tsx|jsx)": ["yarn eslint --cache --fix", "yarn prettier --write", "yarn test --bail --findRelatedTests"],
3+
}

Diff for: commitlint.config.js

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

Diff for: package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@
3030
"storybook": "start-storybook -s ./public -p 6006",
3131
"build-storybook": "build-storybook",
3232
"chromatic": "npx chromatic",
33-
"size": "size-limit"
33+
"size": "size-limit",
34+
"prepare": "husky install"
3435
},
3536
"keywords": [
3637
"uikit"
3738
],
3839
"author": "Cube Dev Team",
3940
"devDependencies": {
4041
"@ant-design/icons": "^4.7.0",
42+
"@commitlint/cli": "16.1.0",
43+
"@commitlint/config-conventional": "16.0.0",
4144
"@open-wc/testing": "^3.0.3",
4245
"@react-aria/button": "^3.3.4",
4346
"@react-aria/checkbox": "^3.2.3",
@@ -119,8 +122,10 @@
119122
"eslint-plugin-react": "^7.28.0",
120123
"eslint-plugin-react-hooks": "^4.3.0",
121124
"eslint-plugin-storybook": "^0.5.5",
125+
"husky": ">=6",
122126
"jest": "^27.4.5",
123127
"less-loader": "^10.2.0",
128+
"lint-staged": ">=10",
124129
"netlify-cli": "^8.6.0",
125130
"parcel-bundler": "^1.12.4",
126131
"prettier": "^2.5.1",

Diff for: yarn.lock

+516-18
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)