-
Notifications
You must be signed in to change notification settings - Fork 963
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (22 loc) · 743 Bytes
/
Copy pathindex.js
File metadata and controls
26 lines (22 loc) · 743 Bytes
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
import path from "node:path";
import configAngular from "@commitlint/config-angular";
import { glob } from "node:fs/promises";
import { merge } from "es-toolkit/compat";
function pathToId(root, filePath) {
const relativePath = path.relative(root, filePath);
return path.dirname(relativePath).split(path.sep).join("/");
}
async function getPatternIDs() {
const root = path.resolve(process.cwd(), "./patterns");
const pattern = path.resolve(root, "**/pattern.json");
const files = [];
for await (const result of glob(pattern)) {
files.push(pathToId(root, result));
}
return files;
}
export default merge(configAngular, {
rules: {
"scope-enum": () => getPatternIDs().then((ids) => [2, "always", ids.concat(["system"])]),
},
});