Repository navigation
Expand file tree
/
Copy pathcommitlint.config.js
More file actions
78 lines (77 loc) · 2.51 KB
/
Copy pathcommitlint.config.js
File metadata and controls
78 lines (77 loc) · 2.51 KB
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
// Conventional Commits rules for PR titles.
//
// DNSControl squash-merges PRs, so the PR *title* becomes the commit
// message on main and is what goreleaser's changelog.groups (.goreleaser.yml)
// matches against. This config is linted in CI against the PR title, not
// against individual commits within the PR (see
// .github/workflows/pr_commitlint.yml).
//
// Provider-specific changes use a scope of "p/PROVIDER", e.g.:
// fix(p/CLOUDFLAREAPI): correct TTL rounding
// feat(p/ROUTE53): support alias records for NS
//
// Everything else uses one of the standard Conventional Commits types.
/** @type {import('@commitlint/types').UserConfig} */
module.exports = {
extends: ["@commitlint/config-conventional"],
parserPreset: {
parserOpts: {
// The default header pattern only allows a single word (\w+) as the
// type. We widen it to also accept the literal types "BREAKING CHANGE"
// and "BREAKING CHANGES", which contain a space.
headerPattern: /^([a-zA-Z ]+)(?:\(([^)]+)\))?(!)?: (.+)$/,
headerCorrespondence: ["type", "scope", "breaking", "subject"],
},
},
rules: {
"type-enum": [
2,
"always",
[
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"style",
"test",
"BREAKING CHANGE",
"BREAKING CHANGES",
],
],
// type-case can't be "always lower-case" since BREAKING CHANGE(S) is
// uppercase by convention; type-enum above already constrains the set
// of allowed values (case-sensitively), so the case rule is redundant.
"type-case": [0],
"scope-case": [0],
"subject-case": [0], // Permit capitalized subjects like "fix(foo): Correct TTL rounding"
"provider-scope-format": [2, "always"],
},
plugins: [
{
rules: {
// If a scope is given, it must be "p/PROVIDER" (provider-specific
// change) or one of the config-conventional defaults are allowed too
// (e.g. "deps" for dependency bumps). Everything else is free-form.
"provider-scope-format": ({ scope }) => {
if (!scope) {
return [true];
}
if (/^p\/[A-Za-z0-9_.-]+$/.test(scope)) {
return [true];
}
if (/^[a-z0-9_.-]+$/i.test(scope)) {
return [true];
}
return [
false,
'scope must be a provider scope like "p/CLOUDFLAREAPI", or a simple word (e.g. "deps")',
];
},
},
},
],
};