Skip to content

Commit

Permalink
docs: Add commitlint example
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Jan 24, 2023
1 parent 040297f commit b84590e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
37 changes: 37 additions & 0 deletions examples/commitlint/README.md
Original file line number Diff line number Diff line change
@@ -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'
```
1 change: 1 addition & 0 deletions examples/commitlint/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']};
12 changes: 12 additions & 0 deletions examples/commitlint/lefthook.yml
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit b84590e

Please sign in to comment.