mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 15:24:10 +08:00
* ci: automate PR title linting This will help with Squash & Merge when you need the squashed commit to have the correct Conventional Commits format so that it can be parsed when generating release notes (With Squash & Merge the squashed commit message is taken from the PR title) * chore: minor updates --------- Co-authored-by: Johann Schopplich <mail@johannschopplich.com>
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import type { Rule, UserConfig } from '@commitlint/types'
|
|
import { RuleConfigSeverity } from '@commitlint/types'
|
|
|
|
// #region Rules
|
|
|
|
/**
|
|
* Rule to ensure the first letter of the commit subject is lowercase.
|
|
*
|
|
* @param parsed - Parsed commit object containing commit message parts.
|
|
* @returns A tuple where the first element is a boolean indicating
|
|
* if the rule passed, and the second is an optional error message.
|
|
*/
|
|
const subjectLowercaseFirst: Rule = async (parsed) => {
|
|
const firstChar = parsed.subject!.match(/[a-z]/i)?.[0]
|
|
if (firstChar && firstChar === firstChar.toUpperCase()) {
|
|
return [false, 'Subject must start with a lowercase letter']
|
|
}
|
|
return [true]
|
|
}
|
|
|
|
// #endregion
|
|
|
|
const Configuration: UserConfig = {
|
|
extends: ['@commitlint/config-conventional'],
|
|
rules: {
|
|
'subject-case': [RuleConfigSeverity.Disabled],
|
|
'subject-lowercase-first': [RuleConfigSeverity.Error, 'always'],
|
|
},
|
|
plugins: [
|
|
{
|
|
rules: {
|
|
'subject-lowercase-first': subjectLowercaseFirst,
|
|
},
|
|
},
|
|
],
|
|
}
|
|
|
|
export default Configuration
|