-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy path.commitlintrc.mjs
More file actions
73 lines (68 loc) · 1.8 KB
/
Copy path.commitlintrc.mjs
File metadata and controls
73 lines (68 loc) · 1.8 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
import {existsSync, readdirSync, readFileSync} from 'node:fs'
import {join} from 'node:path'
function readPackageName(buildFile) {
const match = readFileSync(buildFile, 'utf8').match(
/package_name\s*=\s*"([^"]+)"/
)
return match?.[1]
}
function packageScopes() {
return readdirSync('packages', {withFileTypes: true})
.filter(entry => entry.isDirectory())
.map(entry => join('packages', entry.name, 'BUILD.bazel'))
.filter(buildFile => existsSync(buildFile))
.map(readPackageName)
.filter(Boolean)
}
function crateScopes() {
return readdirSync('crates', {withFileTypes: true})
.filter(entry => entry.isDirectory())
.map(entry => entry.name)
}
const packages = [
...packageScopes(),
...crateScopes(),
// renovate bot config package
'deps',
]
export default {
parserPreset: {
parserOpts: {headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/},
},
rules: {
// Cheatsheet: https://commitlint.js.org/#/reference-rules
// Sweet Jesus why is disabling a rule syntax so verbose??
'subject-exclamation-mark': [2, 'never'],
'body-leading-blank': [1, 'always'],
'footer-leading-blank': [1, 'always'],
'scope-case': [2, 'always', 'lower-case'],
'scope-enum': [2, 'always', packages],
'subject-case': [
2,
'never',
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'header-max-length': [0, 'never', Infinity],
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
],
],
},
}