diff --git a/commitlint.config.mjs b/commitlint.config.mjs index b1e2a180..a0109203 100644 --- a/commitlint.config.mjs +++ b/commitlint.config.mjs @@ -14,6 +14,19 @@ const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => { ] } +// A GitHub App's noreply address alone makes its co-author trailer too long. +const validateFooterMaxLengthIgnoringCoAuthors = (parsedCommit) => { + const footer = (parsedCommit.footer ?? '') + .split('\n') + .filter((line) => !/^co-authored-by:/i.test(line)) + .join('\n') + + return [ + !footer || maxLineLength(footer, bodyMaxLineLength), + `footer's lines must not be longer than ${bodyMaxLineLength}`, + ] +} + export default { extends: ['@commitlint/config-conventional'], plugins: ['commitlint-plugin-function-rules'], @@ -24,5 +37,11 @@ export default { 'always', validateBodyMaxLengthIgnoringDeps, ], + 'footer-max-line-length': [0], + 'function-rules/footer-max-line-length': [ + 2, + 'always', + validateFooterMaxLengthIgnoringCoAuthors, + ], }, }