2 Star 3 Fork 0

Git工具集 / commitlint

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Get Started | Let's chat slack | Website

Lint commit messages

Demo generated with svg-term-cli

cat docs/assets/commitlint.json | svg-term --out docs/assets/commitlint.svg --frame --profile=Seti --height=20 --width=80

npm latest CircleCI

  • 🚓 Be a good commitizen
  • 📦 Share configuration via npm
  • 🤖 Tap into conventional-changelog

Contents


What is commitlint

commitlint checks if your commit messages meet the conventional commit format.

In general the pattern mostly looks like this:

type(scope?): subject  #scope is optional

Real world examples can look like this:

chore: run tests on travis ci
fix(server): send cors headers
feat(blog): add comment section

Common types according to commitlint-config-conventional (based on the the Angular convention) can be:

  • build
  • ci
  • chore
  • docs
  • feat
  • fix
  • perf
  • refactor
  • revert
  • style
  • test

These can be modified by your own configuration.

Benefits using commitlint

Getting started

# Install commitlint cli and conventional config
npm install --save-dev @commitlint/{config-conventional,cli}
# For Windows:
npm install --save-dev @commitlint/config-conventional @commitlint/cli

# Configure commitlint to use conventional config
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js

To lint commits before they are created you can use Husky's 'commit-msg' hook.

Install in your project npm install husky --save-dev or yarn add -D husky.

After that, you can create a .huskyrc file or add to your package.json the following code:

{
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  }
}

Detailed Setup instructions

CLI

  • Primary way to interact with commitlint.
  • npm install --save-dev @commitlint/cli
  • Packages: cli

Config

  • Configuration is picked up from commitlint.config.js, .commitlintrc.js, .commitlintrc.json, or .commitlintrc.yml file or a commitlint field in package.json
  • Packages: cli, core
  • See Rules for a complete list of possible rules
  • An example configuration can be found at @commitlint/config-conventional

Shared configuration

A number of shared configurations are available to install and use with commitlint:

⚠️ If you want to publish your own shareable config then make sure it has a name aligning with the pattern commitlint-config-emoji-log or commitlint-config-your-config-name — then in extend all you have to write is emoji-log or your-config-name.

API

  • Alternative, programmatic way to interact with commitlint
  • Packages:
    • format - Format commitlint reports
    • lint - Lint a string against commitlint rules
    • load - Load shared commitlint configuration
    • read - Read commit messages from a specified range or last edit
  • See API for a complete list of methods and examples

Tools

Roadmap

Ideas: conventional-changelog/commitlint#94

commitlint is considered stable and is used in various projects as development tool.

We identify ease of adoption and developer experience as fields where there is room and need for improvement. The items on the roadmap should enhance commitlint regarding those aspects.

Version Support

  • Node.js LTS >= 8
  • git >= 2.13.2

Related projects

License

Copyright by @marionebl. All commitlint packages are released under the MIT license.

Development

commitlint is developed in a mono repository.

Install and run

git clone git@github.com:conventional-changelog/commitlint.git
cd commitlint
yarn
yarn run build # run build tasks
yarn start # run tests, again on change

For more information on how to contribute please take a look at our contribution guide.

Publishing a release

yarn clean
yarn install
yarn run build
yarn test
yarn run publish
The MIT License (MIT) Copyright (c) 2016 - present Mario Nebl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Lint commit messages 展开 收起
TypeScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/vcs-all-in-one/commitlint.git
git@gitee.com:vcs-all-in-one/commitlint.git
vcs-all-in-one
commitlint
commitlint
master

搜索帮助