Check if your commit messages start with a JIRA ticket identifier and a type.
Accepts commit messages like:
PROJECT-1/feat: implemented a new message handler KEY-729/fix: removed erroneous handling of a key If you want to lint your commits with jira-type, follow along:
- Install the jira-type dependencies
npm i commitlint-plugin-jira-type commitlint-config-jira-type -D - Configure commitlint
// commitlint.config.js module.exports = { plugins: ['commitlint-plugin-jira-type'], extends: ['jira-type'], }
- Setup Husky
// package.json { "husky": { "hooks": { "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } } }
jira-type offers the following configurable rules. By customizing these rules, you can define which messages should be accepted and rejected.
An enumeration of accepted JIRA project keys. If the project key within the message is not included, then the message is rejected. By default, the value of this setting is undefined, which means that every key is accepted.
If you want to accept PROJECTA and PROJECTB only:
// commitlint.config.js module.exports = { plugins: ['commitlint-plugin-jira-type'], extends: ['jira-type'], rules: { // 2 sets the level of this rule to error. // always means that this rule should be applied as is // (the other value is "never", which inverts the rule) 'jira-type-project-key-enum': [2, 'always', ['PROJECTA', 'PROJECTB']] } }An enumeration of accepted types. If the type within the message is not included, then the message is rejected. By default, the value of this setting is undefined, which means that every type is accepted.
If you want to accept feat and fix only:
// commitlint.config.js module.exports = { plugins: ['commitlint-plugin-jira-type'], extends: ['jira-type'], rules: { // 2 sets the level of this rule to error. // always means that this rule should be applied as is // (the other value is "never", which inverts the rule) 'jira-type-type-enum': [2, 'always', ['feat', 'fix']] } }This is a monorepo containing the following packages:
- commitlint-common-jira-type
- Definitions shared between the packages of the monorepo. For example rule names and rule default values.
- commitlint-config-jira-type
- Default configuration for all the rules supported by jira-type.
- commitlint-plugin-jira-type
- The actual rule implementations.