https://github.com/lukebrobbs/commit-hooks
Pre defined Configurable Pre commit hooks
https://github.com/lukebrobbs/commit-hooks
git hooks pre-commit
Last synced: 3 months ago
JSON representation
Pre defined Configurable Pre commit hooks
- Host: GitHub
- URL: https://github.com/lukebrobbs/commit-hooks
- Owner: lukebrobbs
- Created: 2019-04-08T18:52:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T17:26:43.000Z (over 3 years ago)
- Last Synced: 2025-02-19T01:47:09.153Z (over 1 year ago)
- Topics: git, hooks, pre-commit
- Language: JavaScript
- Size: 705 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Commit Hooks
[](https://circleci.com/gh/lukebrobbs/commit-hooks) [](https://codecov.io/gh/lukebrobbs/commit-hooks) [](https://www.npmjs.com/package/ddc-commit-hooks)
DDC-Commit-Hooks is designed to allow the implementation of pre-defined tasks to be implemented during git hooks. These tasks are intended to maximise code quality.
---
## Install
```sh
npm install ddc-commit-hooks --save-dev
```
## Run
To run the package, add the following to your npm scripts:
```sh
ddc-commit
```
this can be followed by the following options :
`-preCommit` - To run all user defined pre commit hooks
`-commitMsg` - To run all user defined commit-message hooks
It is recomended to use this package with [Husky](https://github.com/typicode/husky). Configuration would look as follows:
```js
// .huskyrc
{
"hooks": {
"pre-commit": "npm test && ddc-commit -preCommit",
"commit-msg": "ssc-commit -commitMsg"
}
}
```
## Configuration
To configure Hooks, create a `.commithooksrc` file.
```js
// .commithooksrc
{
"preCommit": {
"maxFileSize": 2,
"esLintCheck": true
}
}
```
It is also possible to create a `commithooks.json` to achieve the same result (Note - content in the `.commithooksrc` file will override `commithooks.json`)
---
## Options
The following options are available in v1.0.0 :
### preCommit
Any of these properties will work inside a `preCommit` key:
| Property | Type | Default | Description |
| ---------------- | --------- | ------- | -------------------------------------------------- |
| **gitlabCi** | `Boolean` | `false` | Checks for the presence of a `.gitlab-ci.yml` file |
| **circleCi** | `Boolean` | `false` | Checks for the presence of a `.circleci` directory |
| **esLintCheck** | `Boolean` | `false` | Checks for the presence of a `.eslintrc` file |
| **maxFileSize** | `Number` | `2` | Max size in mb allowed for any single file |
| **cypress** | `String` | `""` | Directory of cypress tests if applicable |
| **robot** | `String` | `""` | Directory of Robot Framework tests if applicable |
| **dotOnlyCheck** | `Boolean` | `false` | Searches test files for .only |
### commitMsg
Any of these properties will work inside a `commitMsg` key, and will be run on the users commit message:
| Property | Type | Default | Description |
| ------------------- | -------- | ------- | ----------------------------------------------- |
| **_glob_** | `Regex` | `". *"` | Regex patter to check for in the commit title |
| **_maxLineLength_** | `Number` | `79` | Set max line length allowed in a commit message |
| **_titleLength_** | `Number` | `25` | Sets max length for a commit title |