From 7c08e0c945778101cacf1d024dbac4ef87fa82f9 Mon Sep 17 00:00:00 2001 From: PaulBredenberg Date: Fri, 1 Sep 2023 09:27:29 -0400 Subject: [PATCH] fix: disallow fixup! commit messages in our commitlint config --- commitlint.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/commitlint.js b/commitlint.js index 05e4f13..eae5db9 100644 --- a/commitlint.js +++ b/commitlint.js @@ -1,6 +1,7 @@ 'use strict'; -var VALID_TYPES; +var VALID_TYPES, + VALID_PREFIXES; VALID_TYPES = [ 'build', @@ -17,6 +18,11 @@ VALID_TYPES = [ 'test', ]; +VALID_PREFIXES = [ + 'Merge', + 'Revert', +]; + module.exports = { rules: { 'body-leading-blank': [ 2, 'always' ], @@ -43,4 +49,15 @@ module.exports = { VALID_TYPES.concat([ 'sub' ]), ], }, + // The default ignores of commitlint allow prefixes like fixup! and squash!, + // which we don't allow. Therefore, we're turning off defaultIgnores and + // explicitly ignoring only auto-generated merge commit and revert messages + defaultIgnores: false, + ignores: [ + (commit) => { + return VALID_PREFIXES.some((prefix) => { + return commit.startsWith(prefix); + }); + }, + ], };