-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommitlint.config.js
More file actions
34 lines (29 loc) · 850 Bytes
/
commitlint.config.js
File metadata and controls
34 lines (29 loc) · 850 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
27
28
29
30
31
32
33
34
const path = require('path');
const getPackages = async (context) => {
const { globby } = await import('globby');
const ctx = context || {};
const cwd = ctx.cwd || process.cwd();
const { workspaces } = require(path.join(cwd, 'package.json'));
const pJsons = await globby(
workspaces.map((ws) => {
return path.join(ws, 'package.json');
}),
{ cwd }
);
const packages = pJsons.map((pJson) => require(path.join(cwd, pJson)));
return packages
.map((pkg) => pkg.name)
.filter(Boolean)
.map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name));
};
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'scope-enum': (ctx) =>
getPackages(ctx).then((packages) => [
2,
'always',
packages.concat(['scripts', 'deps', 'misc'])
])
}
};