-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcommitlint.config.ts
More file actions
40 lines (35 loc) · 1.06 KB
/
commitlint.config.ts
File metadata and controls
40 lines (35 loc) · 1.06 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
import { readdirSync } from 'node:fs';
import { join } from 'node:path';
import type { UserConfig } from '@commitlint/types';
const getPackages = (dir: string) => {
try {
return readdirSync(dir, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
} catch {
return [];
}
};
const specialScopes = ['global', 'root'];
const packages = getPackages(join(process.cwd(), 'packages'));
const examples = getPackages(join(process.cwd(), 'examples'));
const scopes = [
...specialScopes,
...packages.map((pkg) => `packages/${pkg}`),
...packages.map((pkg) => `${pkg}`),
...examples.map((example) => `examples/${example}`),
...examples.map((example) => `${example}`),
];
const config: UserConfig = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'chore', 'revert'],
],
'scope-enum': [2, 'always', scopes],
'scope-empty': [2, 'never'],
},
};
export default config;