forked from BeOnAuto/auto-engineer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.ts
More file actions
42 lines (37 loc) · 1.2 KB
/
commitlint.config.ts
File metadata and controls
42 lines (37 loc) · 1.2 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
import type { UserConfig } from '@commitlint/types';
import { readdirSync } from 'fs';
import { join } from 'path';
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 apps = getPackages(join(process.cwd(), 'apps'));
const examples = getPackages(join(process.cwd(), 'examples'));
const integrations = getPackages(join(process.cwd(), 'integrations'));
const scopes = [
...specialScopes,
...packages.map((pkg) => `packages/${pkg}`),
...apps.map((app) => `apps/${app}`),
...examples.map((example) => `examples/${example}`),
...integrations.map((integration) => `integrations/${integration}`),
];
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;