File tree 3 files changed +50
-0
lines changed
3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ import message from '@commitlint/message' ;
2
+
3
+ export default ( parsed , when , value ) => {
4
+ const { header} = parsed ;
5
+ const negated = when === 'never' ;
6
+ const hasStop = header [ header . length - 1 ] === value ;
7
+
8
+ return [
9
+ negated ? ! hasStop : hasStop ,
10
+ message ( [ 'header' , negated ? 'may not' : 'must' , 'end with full stop' ] )
11
+ ] ;
12
+ } ;
Original file line number Diff line number Diff line change
1
+ import test from 'ava' ;
2
+ import parse from '@commitlint/parse' ;
3
+ import check from './header-full-stop' ;
4
+
5
+ const messages = {
6
+ with : `header.\n` ,
7
+ without : `header\n`
8
+ } ;
9
+
10
+ const parsed = {
11
+ with : parse ( messages . with ) ,
12
+ without : parse ( messages . without )
13
+ } ;
14
+
15
+ test ( 'with against "always ." should succeed' , async t => {
16
+ const [ actual ] = check ( await parsed . with , 'always' , '.' ) ;
17
+ const expected = true ;
18
+ t . is ( actual , expected ) ;
19
+ } ) ;
20
+
21
+ test ( 'with against "never ." should fail' , async t => {
22
+ const [ actual ] = check ( await parsed . with , 'never' , '.' ) ;
23
+ const expected = false ;
24
+ t . is ( actual , expected ) ;
25
+ } ) ;
26
+
27
+ test ( 'without against "always ." should fail' , async t => {
28
+ const [ actual ] = check ( await parsed . without , 'always' , '.' ) ;
29
+ const expected = false ;
30
+ t . is ( actual , expected ) ;
31
+ } ) ;
32
+
33
+ test ( 'without against "never ." should succeed' , async t => {
34
+ const [ actual ] = check ( await parsed . without , 'never' , '.' ) ;
35
+ const expected = true ;
36
+ t . is ( actual , expected ) ;
37
+ } ) ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export default {
10
10
'footer-max-length' : require ( './footer-max-length' ) ,
11
11
'footer-max-line-length' : require ( './footer-max-line-length' ) ,
12
12
'footer-min-length' : require ( './footer-min-length' ) ,
13
+ 'header-full-stop' : require ( './header-full-stop' ) ,
13
14
'header-max-length' : require ( './header-max-length' ) ,
14
15
'header-min-length' : require ( './header-min-length' ) ,
15
16
'references-empty' : require ( './references-empty' ) ,
You can’t perform that action at this time.
0 commit comments