-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.commitlint.config.js
90 lines (84 loc) · 2.85 KB
/
.commitlint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// CommitLint configuration
// ref: <https://commitlint.js.org/#/reference-configuration>
// v2022-08-20 [rivy]
// spell-checker:ignore (names) commitLint (people) Roy Ivy III * rivy (words) maint
/* @prettier */ // note: (dprint) {.dprint.json}.prettier.associations should contain the name of this file
const isNPMTestDist = !!process.env['npm_config_test_dist'];
const isTestDist = !!process.env['test_dist'];
const isTestRelease = !!process.env['test_release'];
/** Relax linting rules/strictures (for development; *not* when submitting for distribution/release). */
const relaxedReview = !(isNPMTestDist || isTestDist || isTestRelease);
const commitTags = [
'Add',
'Added',
'Bugfix',
'Build',
'Change',
'Changed',
'Chore',
'Deps',
'Docs',
'Feat',
'Fix',
'Fixed',
'Fixes',
'FORK',
'Maint',
'Perf',
'Refactor',
'Style',
'Test',
'Tests',
'Update',
'Updated',
'Upkeep',
// * git automated messages
'Automatic',
'Auto-merged',
'Merge',
'Merged',
'Revert',
// * ok for relaxed review (ie, development), otherwise *not ok*
...(relaxedReview ? ['VERSION', 'WIP', 'X'] : []),
];
module.exports = {
extends: ['@commitlint/config-conventional'],
parserPreset: {
parserOpts: {
// headerPattern ~ tested at <https://regex101.com/r/ez7wQS/1>
headerPattern: /^(\s*\w[\w-]*)(?:\s*(?:[/(]([\w,/]+)[)]?))?!?\s*[~:]?\s*(.*)$/,
headerCorrespondence: ['type', 'scope', 'subject'],
},
},
plugins: [
{
rules: {
'@local/DEBUG': (parsed, when, value) => {
return [true, console.log({ parsed, when, value })];
},
},
},
],
// 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],
// ## maint [2020-01-07; rivy] ~ 'footer-leading-blank' disabled until <https://github.com/conventional-changelog/commitlint/issues/896> is fixed
// ## ... refs: <https://github.com/conventional-changelog/commitlint/issues/896#issuecomment-671865868> , <https://github.com/rook/rook/pull/6499#issuecomment-717267089>
'footer-leading-blank': [0],
'header-max-length': [1, 'always', 90],
'scope-case': [2, 'always', ['camel-case', 'lower-case', 'pascal-case', 'upper-case']],
'subject-case': [0],
'subject-empty': [relaxedReview ? 1 : 2, 'never'],
'type-case': [2, 'always', ['lower-case', 'sentence-case']],
'type-enum': [2, 'always', [...commitTags.map((v) => v.toLowerCase()), ...commitTags]],
},
};