Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

Commit

Permalink
chore: include commitlint to handle better commit messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed Aug 6, 2022
1 parent 03ffddd commit 127bac1
Show file tree
Hide file tree
Showing 4 changed files with 266 additions and 14 deletions.
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"

yarn lint:ci
28 changes: 28 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const {maxLineLength} = require('@commitlint/ensure');

const bodyMaxLineLength = 100;

const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => {
const {type, scope, body} = parsedCommit;

const isDepsCommit =
type === 'chore' && (scope === 'deps' || scope === 'deps-dev');

return [
isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength),
`body's lines must not be longer than ${bodyMaxLineLength}`,
];
};

module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
rules: {
'body-max-line-length': [0],
'function-rules/body-max-line-length': [
2,
'always',
validateBodyMaxLengthIgnoringDeps,
],
},
};
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"publish": "yarn build && cd lib && npm publish && cd ..",
"publish:packages": "yarn pre && yarn build:packages && lerna exec -- npm publish",
"lint": "eslint main packages docs --ext .ts,.tsx,.js,.jsx",
"lint:ci": "commitlint --from HEAD~1 --to HEAD --verbose",
"tsc": "tsc",
"start": "expo start",
"jest": "jest --runInBand",
Expand All @@ -26,7 +27,8 @@
"deploy:storybook": "gh-pages -d web-build",
"build:packages": "lerna exec -- yarn build",
"install:packages": "lerna exec -- yarn",
"upgrade:packages": "lerna exec -- ncu -u && yarn install:packages"
"upgrade:packages": "lerna exec -- ncu -u && yarn install:packages",
"prepare": "husky install"
},
"dependencies": {
"@dooboo-ui/theme": "^0.4.7",
Expand All @@ -53,6 +55,8 @@
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
"@babel/preset-react": "^7.18.6",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@dooboo/eslint-config": "^1.4.0",
"@emotion/babel-plugin": "^11.10.0",
"@jest/types": "^28.1.3",
Expand Down Expand Up @@ -85,9 +89,11 @@
"babel-loader": "^8.2.5",
"babel-preset-expo": "9.2.0",
"babel-preset-react-app": "^10.0.1",
"commitlint-plugin-function-rules": "^1.7.1",
"eslint": "^8.21.0",
"gh-pages": "^4.0.0",
"givens": "^1.3.9",
"husky": "^8.0.0",
"intl": "^1.2.5",
"jest": "^28.1.3",
"jest-expo": "^46.0.1",
Expand Down
Loading

0 comments on commit 127bac1

Please sign in to comment.