# validate-commit-msg **Repository Path**: mirrors_stevemao/validate-commit-msg ## Basic Information - **Project Name**: validate-commit-msg - **Description**: githook to validate commit messages are up to standard - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-26 - **Last Updated**: 2025-10-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # validate-commit-msg [![Build Status][build-badge]][build] [![Code Coverage][coverage-badge]][coverage] [![Dependencies][dependencyci-badge]][dependencyci] [![version][version-badge]][package] [![downloads][downloads-badge]][npm-stat] [![MIT License][license-badge]][LICENSE] [![All Contributors](https://img.shields.io/badge/all_contributors-28-orange.svg?style=flat-square)](#contributors) [![PRs Welcome][prs-badge]][prs] [![Donate][donate-badge]][donate] [![Code of Conduct][coc-badge]][coc] [![Watch on GitHub][github-watch-badge]][github-watch] [![Star on GitHub][github-star-badge]][github-star] [![Tweet][twitter-badge]][twitter] This provides you a binary that you can use as a githook to validate the commit message. I recommend [husky](http://npm.im/husky). You'll want to make this part of the `commit-msg` githook, e.g. when using [husky](http://npm.im/husky), add `"commitmsg": "validate-commit-msg"` to your [npm scripts](https://docs.npmjs.com/misc/scripts) in `package.json`. Validates that your commit message follows this format: ``` (): ``` Or without optional scope: ``` : ``` ## Installation This module is distributed via [npm](https://www.npmjs.com/) which is bundled with [node](https://nodejs.org/) and should be installed as one of your project's `devDependencies`: ``` npm install --save-dev validate-commit-msg ``` ## Usage ### options You can specify options in `.vcmrc` ```js { "types": ["feat", "fix", "docs", "style", "refactor", "perf", "test", "chore", "revert"], // default "scope": { required: false, // default, allowed: ['button', 'card'], // default is '*' for anything, validate: false, // default, multiple: false // default }, "warnOnFail": false, // default "maxSubjectLength": 100, // default "subjectPattern": ".+", // default "subjectPatternErrorMsg": "subject does not match subject pattern!", // default "helpMessage": "", // default "autoFix": false // default } ``` or in `package.json` ```javascript { "config": { "validate-commit-msg": { /* your config here */ } } } ``` `.vcmrc` has precedence, if it does not exist, then `package.json` will be used. #### types These are the types that are allowed for your commit message. If omitted, the value is what is shown above. You can also specify: `"types": "*"` to indicate that you don't wish to validate types. Or you can specify the name of a module that exports types according to the [conventional-commit-types](https://github.com/adjohnson916/conventional-commit-types) spec, e.g. `"types": "conventional-commit-types"`. #### scope This object defines scope requirements for the commit message. Possible properties are: ##### required A boolean to define whether a scope is required for all commit messages. ##### allowed An array of scopes that are allowed for your commit message. You may also define it as `"*"` which is the default to allow any scope names. ##### validate A boolean to define whether or not to validate the scope(s) provided. ##### multiple A boolean to define whether or not to allow multiple scopes. #### warnOnFail If this is set to `true` errors will be logged to the console, however the commit will still pass. #### maxSubjectLength This will control the maximum length of the subject. #### subjectPattern Optional, accepts a RegExp to match the commit message subject against. #### subjectPatternErrorMsg If `subjectPattern` is provided, this message will be displayed if the commit message subject does not match the pattern. #### helpMessage If provided, the helpMessage string is displayed when a commit message is not valid. This allows projects to provide a better developer experience for new contributors. The `helpMessage` also supports interpolating a single `%s` with the original commit message. #### autoFix If this is set to `true`, type will be auto fixed to all lowercase, subject first letter will be lowercased, and the commit will pass (assuming there's nothing else wrong with it). ### Node Through node you can use as follows ```javascript var validateMessage = require('validate-commit-msg'); var valid = validateMessage('chore(index): an example commit message'); // valid = true ``` ### Other notes If the commit message begins with `WIP` then none of the validation will happen. ## Credits This was originally developed by contributors to [the angular.js project](https://github.com/angular/angular.js). I pulled it out so I could re-use this same kind of thing in other projects. [build-badge]: https://img.shields.io/travis/kentcdodds/validate-commit-msg.svg?style=flat-square [build]: https://travis-ci.org/kentcdodds/validate-commit-msg [coverage-badge]: https://img.shields.io/codecov/c/github/kentcdodds/validate-commit-msg.svg?style=flat-square [coverage]: https://codecov.io/github/kentcdodds/validate-commit-msg [dependencyci-badge]: https://dependencyci.com/github/kentcdodds/validate-commit-msg/badge?style=flat-square [dependencyci]: https://dependencyci.com/github/kentcdodds/validate-commit-msg [version-badge]: https://img.shields.io/npm/v/validate-commit-msg.svg?style=flat-square [package]: https://www.npmjs.com/package/validate-commit-msg [downloads-badge]: https://img.shields.io/npm/dm/validate-commit-msg.svg?style=flat-square [npm-stat]: http://npm-stat.com/charts.html?package=validate-commit-msg&from=2016-04-01 [license-badge]: https://img.shields.io/npm/l/validate-commit-msg.svg?style=flat-square [license]: https://github.com/kentcdodds/validate-commit-msg/blob/master/LICENSE [prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square [prs]: http://makeapullrequest.com [donate-badge]: https://img.shields.io/badge/$-support-green.svg?style=flat-square [donate]: http://kcd.im/donate [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square [coc]: https://github.com/kentcdodds/validate-commit-msg/blob/master/CODE_OF_CONDUCT.md [github-watch-badge]: https://img.shields.io/github/watchers/kentcdodds/validate-commit-msg.svg?style=social [github-watch]: https://github.com/kentcdodds/validate-commit-msg/watchers [github-star-badge]: https://img.shields.io/github/stars/kentcdodds/validate-commit-msg.svg?style=social [github-star]: https://github.com/kentcdodds/validate-commit-msg/stargazers [twitter]: https://twitter.com/intent/tweet?text=Check%20out%20validate-commit-msg!%20https://github.com/kentcdodds/validate-commit-msg%20%F0%9F%91%8D [twitter-badge]: https://img.shields.io/twitter/url/https/github.com/kentcdodds/validate-commit-msg.svg?style=social ## Contributors Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): | [
Kent C. Dodds](https://kentcdodds.com)
πŸ’ [πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=kentcdodds) [πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=kentcdodds) πŸ‘€ [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=kentcdodds) | [
Remy Sharp](http://remysharp.com)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=remy) [πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=remy) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=remy) | [
CΓ©dric Malard](http://valdun.net)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=cmalard) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=cmalard) | [
Mark Dalgleish](http://markdalgleish.com)
[πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=markdalgleish) | [
Ryan Kimber](https://formhero.io)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=ryan-kimber) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=ryan-kimber) | [
Javier Collado](https://github.com/jcollado)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=jcollado) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=jcollado) | [
Jamis Charles](https://github.com/jamischarles)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=jamischarles) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=jamischarles) | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | [
Shawn Erquhart](http://www.professant.com)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=erquhart) [πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=erquhart) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=erquhart) | [
Tushar Mathur](http://tusharm.com)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=tusharmath) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=tusharmath) | [
Jason Dreyzehner](https://twitter.com/bitjson)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=bitjson) [πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=bitjson) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=bitjson) | [
Abimbola Idowu](http://twitter.com/hisabimbola)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=hisabimbola) | [
Gleb Bahmutov](https://glebbahmutov.com/)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=bahmutov) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=bahmutov) | [
Dennis](http://dennis.io)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=ds82) | [
Matt Lewis](https://mattlewis.me/)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=mattlewis92) | | [
Tom Vincent](https://tlvince.com)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=tlvince) | [
Anders D. Johnson](https://andrz.me/)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=adjohnson916) [πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=adjohnson916) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=adjohnson916) | [
James Zetlen](http://jameszetlen.com)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=zetlen) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=zetlen) | [
Paul Bienkowski](http://opatut.de)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=opatut) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=opatut) | [
Barney Scott](https://github.com/bmds)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=bmds) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=bmds) | [
Emmanuel Murillo SΓ‘nchez](https://github.com/Emmurillo)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=Emmurillo) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=Emmurillo) | [
Hans Kristian Flaatten](https://starefossen.github.io)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=Starefossen) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=Starefossen) | | [
Bo Lingen](https://github.com/citycide)
[πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=citycide) | [
Spyros Ioakeimidis](http://www.spyros.io)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=spirosikmd) [πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=spirosikmd) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=spirosikmd) | [
Matt Travi](https://matt.travi.org)
[πŸ›](https://github.com/kentcdodds/validate-commit-msg/issues?q=author%3Atravi) | [
Jonathan Garbee](http://jonathan.garbee.me)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=Garbee) [πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=Garbee) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=Garbee) | [
Tobias Lins](https://lins.in)
[πŸ“–](https://github.com/kentcdodds/validate-commit-msg/commits?author=tobiaslins) | [
Max Claus Nunes](http://blog.maxcnunes.net/)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=maxcnunes) | [
standy](https://github.com/standy)
[πŸ’»](https://github.com/kentcdodds/validate-commit-msg/commits?author=standy) [⚠️](https://github.com/kentcdodds/validate-commit-msg/commits?author=standy) | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!