File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 11module . exports = {
22 extends : [ '@commitlint/config-conventional' ] ,
3+ plugins : [
4+ {
5+ rules : {
6+ 'header-max-length-deps' : ( parsed ) => {
7+ const config = {
8+ maxLength : 100 ,
9+ dependencyCommit : {
10+ type : / ^ ( c h o r e | f i x ) / ,
11+ scope : / ( p e e r - ) ? d e p s / ,
12+ maxLength : 200 ,
13+ } ,
14+ } ;
15+
16+ const length = parsed . header . length ;
17+ const isDepsCommit =
18+ config . dependencyCommit . type . test ( parsed . type ) &&
19+ config . dependencyCommit . scope . test ( parsed . scope ) ;
20+
21+ if ( length <= config . maxLength ) {
22+ return [ true ] ;
23+ }
24+
25+ if ( ! isDepsCommit && length > config . maxLength ) {
26+ return [
27+ false ,
28+ [
29+ `header must not be longer than ${ config . maxLength } ` ,
30+ `characters, current length is ${ length } ` ,
31+ ] . join ( ' ' ) ,
32+ ] ;
33+ }
34+
35+ if ( isDepsCommit && length > config . dependencyCommit . maxLength ) {
36+ return [
37+ false ,
38+ [
39+ `header for dependency commits must not be longer than` ,
40+ `${ config . dependencyCommit . maxLength } characters, current` ,
41+ `length is ${ length } ` ,
42+ ] . join ( ' ' ) ,
43+ ] ;
44+ }
45+
46+ return [ true ] ;
47+ } ,
48+ } ,
49+ } ,
50+ ] ,
51+ rules : {
52+ 'body-max-line-length' : [ 0 ] ,
53+ 'footer-max-line-length' : [ 0 ] ,
54+ 'header-max-length' : [ 0 ] ,
55+ 'header-max-length-deps' : [ 2 , 'always' ] ,
56+ } ,
357} ;
You can’t perform that action at this time.
0 commit comments