Commitlint code Commitlint

function

Prevent developers from writing commit, and make commit accessible to everyone, but this requires some English help

The installation

yarn add --dev husky @commitlint/cli @commitlint/config-conventional

use

Create the.commitlintrc.js file in the project root directory

module.exports = { extends: ['@commitlint/config-conventional'], rules: { 'subject-case': [0, 'never'], 'type-enum': [2, 'always', ['build', // construct 'CI ', // CI 'chore', // Change build process or add dependent libraries, tools, etc. 'docs', // only modify docs, Such as README 'feat', // add feature 'fix', // fix bug 'perf', // optimize related, such as improve performance, experience 'refactor', // code refactoring, No new features or bug fixes 'revert', // rollback to previous version 'style', // only changes to whitespace, indent, etc., does not change code logic 'test' // Test cases, including unit tests, integration tests, etc.]}}Copy the code

Modify the package.json file

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

\