Skip to content

Commit

Permalink
maint/dev ~ update CommitLint configuration
Browse files Browse the repository at this point in the history
- remove default ignores (avoids automatic ignore of `fixup!`/`squash!` commits)
- capture 'type' text with leading whitespace and/or internal '-'
- allow 'FORK' and 'VERSION' (from older commits) as commit tags
- allow `git` auto-generated message 'types' (and segregate for clarity)
- allow fixup!/squash! commits iff not prerelease
  - note: 'prerelease' (or pre-publish) condition is signalled by `--test-dist` (aka, `!!process.env['npm_config_test_dist]`)
  • Loading branch information
rivy committed Aug 13, 2022
1 parent 6f5f382 commit b523f92
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions .commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// CommitLint configuration
// ref: <https://commitlint.js.org/#/reference-configuration>
// v2022-07-30 [rivy]
// v2022-08-09 [rivy]

// spell-checker:ignore (names) commitLint (people) Roy Ivy III * rivy (words) maint

const isNPMTestDist = !!process.env['npm_config_test_dist'];
const relaxedReview = !isNPMTestDist;

const commitTags = [
'Add',
'Added',
Expand All @@ -17,25 +20,32 @@ const commitTags = [
'Fix',
'Fixed',
'Fixes',
'FORK',
'Maint',
'Merge',
'Perf',
'Refactor',
'Revert',
'Style',
'Test',
'Tests',
'Update',
'Updated',
'Upkeep',
'VERSION',
'WIP',
// * git automated messages
'Automatic',
'Auto-merged',
'Merge',
'Merged',
'Revert',
];

module.exports = {
extends: ['@commitlint/config-conventional'],
parserPreset: {
parserOpts: {
headerPattern: /^(\w+)!?(?:\s*(?:[/(]([\w,/]+)[)]?))?!?\s*[~:]?\s*(.*)$/,
// headerPattern ~ tested at <https://regex101.com/r/ez7wQS/1>
headerPattern: /^(\s*\w[\w-]*)(?:\s*(?:[/(]([\w,/]+)[)]?))?!?\s*[~:]?\s*(.*)$/,
headerCorrespondence: ['type', 'scope', 'subject'],
},
},
Expand All @@ -48,6 +58,15 @@ module.exports = {
},
},
],
// ref: [Commit messages starting with fixup! do not trigger any errors](https://github.com/conventional-changelog/commitlint/issues/3206)
// ref: [tests for default ignores](https://github.com/conventional-changelog/commitlint/blob/914782aad70d353b/%40commitlint/is-ignored/src/defaults.ts#L20-L26)
defaultIgnores: false,
ignores: [
(msg) => msg.match(/^\s*\d+([.]\d+)*/) /* version commit */,
relaxedReview
? (msg) => msg.match(/^\s*(fixup|squash)!/) /* fixup! or squash! commit */
: undefined,
].filter((v) => v != null),
rules: {
// '@local/DEBUG': [1, 'always'],
'body-max-line-length': [0],
Expand Down

0 comments on commit b523f92

Please sign in to comment.