File tree 3 files changed +33
-0
lines changed
3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {scopeEnum} from './scope-enum';
21
21
import { scopeMaxLength } from './scope-max-length' ;
22
22
import { scopeMinLength } from './scope-min-length' ;
23
23
import { signedOffBy } from './signed-off-by' ;
24
+ import { subjectBreaking } from './subject-breaking' ;
24
25
import { subjectCase } from './subject-case' ;
25
26
import { subjectEmpty } from './subject-empty' ;
26
27
import { subjectFullStop } from './subject-full-stop' ;
@@ -58,6 +59,7 @@ export default {
58
59
'scope-max-length' : scopeMaxLength ,
59
60
'scope-min-length' : scopeMinLength ,
60
61
'signed-off-by' : signedOffBy ,
62
+ 'subject-breaking' : subjectBreaking ,
61
63
'subject-case' : subjectCase ,
62
64
'subject-empty' : subjectEmpty ,
63
65
'subject-full-stop' : subjectFullStop ,
Original file line number Diff line number Diff line change
1
+ import parse from '@commitlint/parse' ;
2
+ import { subjectBreaking } from './subject-breaking' ;
3
+
4
+ const messages = {
5
+ empty : 'test: \nbody' ,
6
+ filled : 'BREAKING CHANGE: this one' ,
7
+ } ;
8
+
9
+ const parsed = {
10
+ empty : parse ( messages . empty ) ,
11
+ filled : parse ( messages . filled ) ,
12
+ } ;
13
+
14
+ test ( 'without subject should succeed' , async ( ) => {
15
+ const [ actual ] = subjectBreaking ( await parsed . empty ) ;
16
+ const expected = true ;
17
+ expect ( actual ) . toEqual ( expected ) ;
18
+ } ) ;
19
+
20
+ test ( 'subject fail with BREAKING CHANGE:' , async ( ) => {
21
+ const [ actual ] = subjectBreaking ( await parsed . filled ) ;
22
+ const expected = false ;
23
+ expect ( actual ) . toEqual ( expected ) ;
24
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { SyncRule } from '@commitlint/types' ;
2
+
3
+ export const subjectBreaking : SyncRule = ( parsed ) => {
4
+ const result = parsed . subject ?. startsWith ( 'BREAKING CHANGE:' ) ;
5
+
6
+ return [ ! result , 'move BREAKING CHANGE: to footer' ] ;
7
+ } ;
You can’t perform that action at this time.
0 commit comments