From c9b9b27f1df2637fd20d06ca992841d085a1b459 Mon Sep 17 00:00:00 2001 From: Matt Luedke Date: Wed, 21 Aug 2019 13:53:47 -0400 Subject: [PATCH] feat: Limit scopes to the set of available types (#49) --- commitlint.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/commitlint.js b/commitlint.js index f6be06d..676b125 100644 --- a/commitlint.js +++ b/commitlint.js @@ -1,5 +1,21 @@ 'use strict'; +var VALID_TYPES; + +VALID_TYPES = [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test', +]; + module.exports = { rules: { 'body-leading-blank': [ 2, 'always' ], @@ -8,7 +24,7 @@ module.exports = { 'footer-max-line-length': [ 2, 'always', 90 ], 'header-max-length': [ 2, 'always', 72 ], 'scope-case': [ 2, 'always', [ 'lower-case', 'kebab-case' ] ], - 'scope-empty': [ 2, 'always' ], + 'scope-enum': [ 2, 'always', VALID_TYPES ], 'subject-case': [ 2, 'never', @@ -21,20 +37,9 @@ module.exports = { 'type-enum': [ 2, 'always', - [ - 'build', - 'chore', - 'ci', - 'docs', - 'feat', - 'fix', - 'perf', - 'refactor', - 'revert', - 'style', - 'test', - 'sub', - ], + // In addition to the standard types, allow "sub" for commits that support a + // larger feature, fix, etc. + VALID_TYPES.concat([ 'sub' ]), ], }, };