-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitlint.config.cjs
41 lines (39 loc) · 1.07 KB
/
commitlint.config.cjs
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
const fs = require('node:fs');
/** @type {import('@commitlint/types').UserConfig} */
module.exports = {
extends: ['@commitlint/config-conventional'],
prompt: {
questions: {
scope: {
enum: [
// Add all folders in the 'apps' and 'packages' directories as scopes
...getFoldersInDirectory('apps'),
...getFoldersInDirectory('packages'),
],
description: 'What is the scope of this change (e.g. component or file name)?',
},
},
},
rules: {
'scope-enum': [
2,
'always',
[
// Add all folders in the 'apps' and 'packages' directories as scopes
...getFoldersInDirectory('apps'),
...getFoldersInDirectory('packages'),
],
],
},
};
/**
* Get all folders in a directory
* @param {string} directory Path to load
* @returns {string[]} List of folders
*/
function getFoldersInDirectory(directory) {
return fs
.readdirSync(directory, {withFileTypes: true})
.filter((entry) => entry.isDirectory() && entry.name.startsWith('.'))
.map((entry) => entry.name);
}