diff --git a/examples/commitlint/README.md b/examples/commitlint/README.md new file mode 100644 index 00000000..ca5f48fd --- /dev/null +++ b/examples/commitlint/README.md @@ -0,0 +1,37 @@ +# Use commitlint and/or commitzen + +## Install dependencies + +```bash +yarn add -D @commitlint/cli @commitlint/config-conventional +# If using commitzen +yarn add -D commitizen cz-conventional-changelog +``` + +## Configure + +Setup `commitlint.config.js`. Conventional configuration: + +```bash +echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js +``` + +If you are using commitzen, make sure to add this in `package.json`: + +```json +"config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } +} +``` + +## Test it + +```bash +# You can type it without message, if you are using commitzen +git commit + +# Or provide a commit message is using only commitlint +git commit -am 'fix: typo' +``` diff --git a/examples/commitlint/commitlint.config.js b/examples/commitlint/commitlint.config.js new file mode 100644 index 00000000..3347cb96 --- /dev/null +++ b/examples/commitlint/commitlint.config.js @@ -0,0 +1 @@ +module.exports = {extends: ['@commitlint/config-conventional']}; diff --git a/examples/commitlint/lefthook.yml b/examples/commitlint/lefthook.yml new file mode 100644 index 00000000..a85f7016 --- /dev/null +++ b/examples/commitlint/lefthook.yml @@ -0,0 +1,12 @@ +# Use this to build commit messages +prepare-commit-msg: + commands: + commitzen: + interactive: true + run: LEFTHOOK=0 yarn run cz + +# Use this to validate commit messages +commit-msg: + commands: + "lint commit message": + run: yarn run commitlint --edit {1}