|
| 1 | +import config from '@commitlint/config-conventional'; |
| 2 | +import { RuleConfigSeverity, type UserConfig } from '@commitlint/types'; |
| 3 | +import { getProjects } from '@nx/devkit'; |
| 4 | +import { FsTree } from 'nx/src/generators/tree'; |
| 5 | + |
| 6 | +const projects = getProjects(new FsTree(process.cwd(), false)); |
| 7 | +const scopes = [ |
| 8 | + ...[...projects] |
| 9 | + .filter( |
| 10 | + ([, { projectType }]) => |
| 11 | + projectType === 'library' || projectType === 'application', |
| 12 | + ) |
| 13 | + .map(([name]) => name), |
| 14 | + 'tools', |
| 15 | + 'workflows', |
| 16 | + 'testing', |
| 17 | +].sort(); |
| 18 | + |
| 19 | +const configuration: UserConfig = { |
| 20 | + extends: ['@commitlint/config-conventional'], |
| 21 | + plugins: ['commitlint-plugin-tense'], |
| 22 | + rules: { |
| 23 | + 'scope-enum': [RuleConfigSeverity.Error, 'always', scopes], |
| 24 | + 'type-enum': () => { |
| 25 | + const defaultTypes = config.rules['type-enum'][2]; |
| 26 | + const types = [ |
| 27 | + ...defaultTypes, |
| 28 | + 'release', // custom type for release commits |
| 29 | + ]; |
| 30 | + return [RuleConfigSeverity.Error, 'always', types]; |
| 31 | + }, |
| 32 | + 'tense/subject-tense': [ |
| 33 | + RuleConfigSeverity.Error, |
| 34 | + 'always', |
| 35 | + { firstOnly: true, allowedTenses: ['present-imperative'] }, |
| 36 | + ], |
| 37 | + }, |
| 38 | +}; |
| 39 | + |
| 40 | +module.exports = configuration; |
0 commit comments