Skip to content

Commit

Permalink
chore: setup git hooks
Browse files Browse the repository at this point in the history
- add "husky" for git hooks
- add "commitlint" to enforce consistent commit messages
- add "lint-staged" to run tools against staged files
- modify "CONTRIBUTING" to include the commit message format
  • Loading branch information
hasezoey committed Dec 4, 2020
1 parent b6e8d29 commit c2e3b79
Show file tree
Hide file tree
Showing 6 changed files with 1,316 additions and 42 deletions.
74 changes: 74 additions & 0 deletions .github/CONTRIBUTING.md
Expand Up @@ -18,3 +18,77 @@
---

Note: All Pull Request will get squash merged, so no need for force-pushing

## Commit Structure

This Repository uses the [Angular Commit Message Format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines)
This format is used by `semantic-release` to automatically release new versions based on changes

### Commit Message Format

Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
format that includes a **type**, a **scope** and a **subject**:

```txt
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

The **header** is mandatory and the **scope** of the header is optional.

Any line of the commit message cannot be longer than 100 characters! This allows the message to be easier
to read on GitHub as well as in various git tools.

### Revert

If the commit reverts a previous commit, it should begin with `revert:`, followed by the header
of the reverted commit.
In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit
being reverted.

### Type

Must be one of the following:

* **feat**: A new feature
* **fix**: A bug fix
* **docs**: Documentation only changes
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
* **refactor**: A code change that neither fixes a bug nor adds a feature
* **perf**: A code change that improves performance
* **test**: Adding missing or correcting existing tests
* **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation
* **revert**: Revert an commit
* **dependencies**: Update field `dependencies` (/ `devDependencies`)
* **release**: An Release Commit

look into [releaserc](../.releaserc.js) for corresponding versions

### Scope

The scope could be anything specifying place of the commit change. For example the file that got modified

You can use `*` when the change affects more than a single scope.

### Subject

The subject contains succinct description of the change:

* use the imperative, present tense: "change" not "changed" nor "changes"
* don't capitalize first letter
* no dot (.) at the end

### Body

Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

### Footer

The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit closes

**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines.
The rest of the commit message is then used for this.
10 changes: 10 additions & 0 deletions commitlint.config.js
@@ -0,0 +1,10 @@
module.exports = {
"extends": [
"@commitlint/config-conventional"
],
"rules": {
"scope-case": [0, "never"],
"body-min-length": [2, "always", 3],
"type-enum": [2, "always", ['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'chore', 'revert', 'dependencies', 'release']]
}
};
6 changes: 6 additions & 0 deletions husky.config.js
@@ -0,0 +1,6 @@
module.exports = {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
};
3 changes: 3 additions & 0 deletions lint-staged.config.js
@@ -0,0 +1,3 @@
module.exports = {
"**/*.{ts,js}": "tslint --fix"
};

0 comments on commit c2e3b79

Please sign in to comment.