Skip to content

Commit

Permalink
chore: relax rules to not have to provide ticket number in scope (#1605)
Browse files Browse the repository at this point in the history
Co-authored-by: Philip Bardy <146740183+pbardy2000@users.noreply.github.com>
  • Loading branch information
matthew2564 and pbardy2000 authored Oct 29, 2024
1 parent bb3528e commit 68d0816
Showing 1 changed file with 16 additions and 39 deletions.
55 changes: 16 additions & 39 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,19 @@
// https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/index.js
// https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-rules.md
module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
rules: {
'type-enum': [
2,
'always',
// in addtition to angular defaults, we add additional type for commits, breaking, breaking_change will force a major release with semantic-release
// any body of commit containing BREAKING_CHANGE, BREAKING, etc.. will do too, please refer to the .releaserc.json file
['revert', 'feat', 'test', 'perf', 'fix', 'chore', 'ci', 'docs', 'breaking_change', 'breaking', 'refactor'],
],
'subject-case': [1, 'always', 'lower-case'],
// disable it to allow release notes from semantic-release to happen when releasing
'footer-max-line-length': [0],
'body-max-line-length': [0],
// level: disabled to use our own rule with commitlint-plugin-function-rules plugin
'scope-case': [0],
'function-rules/scope-empty': [
2,
'always',
(parsed) => {
const ticketNumberFormat = /^[a-z0-9]+-\d+$/;
// type(scope?): subject
// we want to ticket number to appear in the commit msg as well as scope when we release
if (
parsed &&
((parsed.scope && parsed.scope.match(ticketNumberFormat) !== null) || parsed.scope === 'release')
) {
return [true];
} else {
return [
false,
`scope must follow the format defined in the commitlint config. The current format is ${ticketNumberFormat}`,
];
}
},
],
},
};

extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
rules: {
'type-enum': [
2,
'always',
// in addtition to angular defaults, we add additional type for commits, breaking, breaking_change will force a major release with semantic-release
// any body of commit containing BREAKING_CHANGE, BREAKING, etc.. will do too, please refer to the .releaserc.json file
['revert', 'feat', 'test', 'perf', 'fix', 'chore', 'ci', 'docs', 'breaking_change', 'breaking', 'refactor'],
],
'subject-case': [1, 'always', 'lower-case'],
// disable it to allow release notes from semantic-release to happen when releasing
'footer-max-line-length': [0],
'body-max-line-length': [0],
},
};

0 comments on commit 68d0816

Please sign in to comment.