-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommitlint.config.ts
More file actions
32 lines (29 loc) · 1.12 KB
/
commitlint.config.ts
File metadata and controls
32 lines (29 loc) · 1.12 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
import type { UserConfig } from '@commitlint/types';
import { RuleConfigSeverity } from '@commitlint/types';
export default {
plugins: [
{
rules: {
'header-match-regex': (parsed, when, regExp: unknown) => {
const isRegExp = (v: unknown): v is RegExp => v instanceof RegExp;
if (!isRegExp(regExp)) throw new Error('Missing regExp.');
const { header } = parsed;
const matched = (header ?? '').match(new RegExp(regExp, 'g')) != null;
return [
matched,
`commit message does not match the pattern: "${regExp.toString()}"`,
];
},
},
},
],
rules: {
'header-match-regex': [RuleConfigSeverity.Error, 'always', /^[A-Z0-9]+-\d+: [^a-z].*/],
'header-max-length': [RuleConfigSeverity.Error, 'always', 100],
'header-full-stop': [RuleConfigSeverity.Error, 'never', '.'],
'body-full-stop': [RuleConfigSeverity.Error, 'always', '.'],
'body-case': [RuleConfigSeverity.Error, 'always', 'sentence-case'],
'body-leading-blank': [RuleConfigSeverity.Error, 'always'],
},
helpUrl: 'README.md',
} satisfies UserConfig;