File tree 1 file changed +18
-4
lines changed
@commitlint/core/src/rules
1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 1
1
import ensureCase from '../library/ensure-case' ;
2
2
import message from '../library/message' ;
3
3
4
+ const negated = when => when === 'never' ;
5
+
4
6
export default ( parsed , when , value ) => {
5
7
const { subject} = parsed ;
6
8
7
- if ( ! subject ) {
9
+ if ( typeof subject !== 'string' ) {
8
10
return [ true ] ;
9
11
}
10
12
11
- const negated = when === 'never' ;
13
+ const checks = ( Array . isArray ( value ) ? value : [ value ] ) . map ( check => {
14
+ if ( typeof check === 'string' ) {
15
+ return {
16
+ when : 'always' ,
17
+ case : check
18
+ } ;
19
+ }
20
+ return check ;
21
+ } ) ;
22
+
23
+ const result = checks . every ( check => {
24
+ const r = ensureCase ( subject , check . case ) ;
25
+ return negated ( check . when ) ? ! r : r ;
26
+ } ) ;
12
27
13
- const result = ensureCase ( subject , value ) ;
14
28
return [
15
- negated ? ! result : result ,
29
+ negated ( when ) ? ! result : result ,
16
30
message ( [ `subject must` , negated ? `not` : null , `be ${ value } ` ] )
17
31
] ;
18
32
} ;
You can’t perform that action at this time.
0 commit comments