-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.ts
More file actions
49 lines (42 loc) · 1.18 KB
/
commitlint.config.ts
File metadata and controls
49 lines (42 loc) · 1.18 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
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
interface ReleaseRule {
type: string;
release: string;
}
interface ReleaseConfig {
plugins: Array<string | [string, Record<string, unknown>]>;
}
// Read release config to keep commit types in sync
const releaseConfig: ReleaseConfig = JSON.parse(
readFileSync(resolve(__dirname, ".releaserc.json"), "utf8")
);
// Extract types from commit-analyzer releaseRules
const commitAnalyzerPlugin = releaseConfig.plugins.find(
(plugin): plugin is [string, { releaseRules?: ReleaseRule[] }] =>
Array.isArray(plugin) && plugin[0] === "@semantic-release/commit-analyzer"
);
const releaseRules = commitAnalyzerPlugin?.[1]?.releaseRules;
const types = releaseRules?.map((rule: ReleaseRule) => rule.type) ?? [
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
"ci",
"chore",
"revert",
];
export default {
extends: ["@commitlint/config-conventional"],
rules: {
"type-enum": [2, "always", types],
"subject-case": [2, "always", "lower-case"],
"header-max-length": [2, "always", 100],
},
};