Skip to content

Commit ee53de7

Browse files
committed
chore(repo): Setup commitlint.config.js without lerna
1 parent 30d1c58 commit ee53de7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

commitlint.config.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
const {
2-
utils: { getPackages },
3-
} = require('@commitlint/config-lerna-scopes');
1+
const glob = require('glob');
2+
const fs = require('fs');
3+
4+
const getPackageNames = () => {
5+
const files = glob.sync('./packages/*/package.json');
6+
const names = files.map(f => JSON.parse(fs.readFileSync(f, 'utf8')).name);
7+
return names.map(n => n.split('/').pop());
8+
};
49

510
module.exports = {
611
extends: ['@commitlint/config-conventional'],
712
rules: {
813
'subject-case': [2, 'always', ['sentence-case']],
914
'body-max-line-length': [1, 'always', '150'],
1015
'scope-empty': [2, 'never'],
11-
'scope-enum': async ctx => [2, 'always', [...(await getPackages(ctx)), 'repo', 'release']],
16+
'scope-enum': async ctx => [2, 'always', [...getPackageNames(), 'repo', 'release']],
1217
},
1318
};

0 commit comments

Comments
 (0)