forked from permaweb/ao
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitlint.config.cjs
40 lines (37 loc) · 1.27 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
const fs = require('node:fs');
const path = require('node:path');
function findDirectories(srcDir, {ignore = [] } = {}) {
return fs.readdirSync(srcDir).filter((file) => {
if (ignore.includes(file)) return false
if (file.startsWith('.')) return false // ignore hidden directories
return fs.statSync(path.join(srcDir, file)).isDirectory()
})
}
/**
* A function that given a list of allowed scopes
* will enforce CommitLint rules:
*
* - A scope is always provided in the commit message
* - The scope is one or multiple of the allowed scopes
*
* See https://www.conventionalcommits.org/en/v1.0.0/#commit-message-with-scope for scopes
* when using conventional commits
*
* @param {string[]} scopes - an array of allowed scopes
*/
const RequireScopes = (scopes) => ({
'scope-empty': [2, 'never'],
'scope-enum': [2, 'always', scopes]
})
module.exports = {
extends: [
'@commitlint/config-conventional'
],
rules: {
...RequireScopes([
'repo', // denotes repo-wide changes ie. monorepo tooling, monorepo docs etc.
...findDirectories(path.join(__dirname, 'servers')), // server projects ie. mu,cu,su,ur
...findDirectories(__dirname, { ignore: ['servers', 'node_modules', 'logos', 'design'] }) // all other top level projects in monorepo
])
}
}