File tree 21 files changed +57
-71
lines changed
21 files changed +57
-71
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,12 @@ const bodyCase: Rule<ensure.TargetCaseType> = (
7
7
when = 'always' ,
8
8
value = undefined
9
9
) => {
10
- const { body} = parsed ;
11
-
12
- if ( ! body ) {
10
+ if ( ! parsed . body ) {
13
11
return [ true ] ;
14
12
}
15
13
16
14
const negated = when === 'never' ;
17
- const result = ensure . case ( body , value ) ;
15
+ const result = ensure . case ( parsed . body , value ) ;
18
16
19
17
return [
20
18
negated ? ! result : result ,
Original file line number Diff line number Diff line change 1
1
import { maxLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const bodyMaxLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
5
- const input = parsed . body ;
6
-
7
- if ( ! input ) {
4
+ const bodyMaxLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
+ if ( ! parsed . body ) {
8
6
return [ true ] ;
9
7
}
10
8
11
9
return [
12
- maxLength ( input , value ) ,
10
+ maxLength ( parsed . body , value ) ,
13
11
`body must not be longer than ${ value } characters`
14
12
] ;
15
13
} ;
Original file line number Diff line number Diff line change @@ -3,17 +3,15 @@ import {Rule} from './types';
3
3
4
4
const bodyMaxLineLength : Rule < number > = (
5
5
parsed ,
6
- when = 'always' ,
6
+ when = undefined ,
7
7
value = 0
8
8
) => {
9
- const input = parsed . body ;
10
-
11
- if ( ! input ) {
9
+ if ( ! parsed . body ) {
12
10
return [ true ] ;
13
11
}
14
12
15
13
return [
16
- maxLineLength ( input , value ) ,
14
+ maxLineLength ( parsed . body , value ) ,
17
15
`body's lines must not be longer than ${ value } characters`
18
16
] ;
19
17
} ;
Original file line number Diff line number Diff line change 1
1
import { minLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const bodyMinLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
4
+ const bodyMinLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
5
if ( ! parsed . body ) {
6
6
return [ true ] ;
7
7
}
Original file line number Diff line number Diff line change 1
1
import { maxLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const footerMaxLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
5
- const input = parsed . footer ;
6
-
7
- if ( ! input ) {
4
+ const footerMaxLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
+ if ( ! parsed . footer ) {
8
6
return [ true ] ;
9
7
}
10
8
11
9
return [
12
- maxLength ( input , value ) ,
10
+ maxLength ( parsed . footer , value ) ,
13
11
`footer must not be longer than ${ value } characters`
14
12
] ;
15
13
} ;
Original file line number Diff line number Diff line change @@ -3,17 +3,15 @@ import {Rule} from './types';
3
3
4
4
const footerMaxLineLength : Rule < number > = (
5
5
parsed ,
6
- when = 'always' ,
6
+ when = undefined ,
7
7
value = 0
8
8
) => {
9
- const input = parsed . footer ;
10
-
11
- if ( ! input ) {
9
+ if ( ! parsed . footer ) {
12
10
return [ true ] ;
13
11
}
14
12
15
13
return [
16
- maxLineLength ( input , value ) ,
14
+ maxLineLength ( parsed . footer , value ) ,
17
15
`footer's lines must not be longer than ${ value } characters`
18
16
] ;
19
17
} ;
Original file line number Diff line number Diff line change 1
1
import { minLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const footerMinLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
4
+ const footerMinLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
5
if ( ! parsed . footer ) {
6
6
return [ true ] ;
7
7
}
Original file line number Diff line number Diff line change 1
1
import { maxLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const headerMaxLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
4
+ const headerMaxLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
5
return [
6
6
maxLength ( parsed . header , value ) ,
7
7
`header must not be longer than ${ value } characters, current length is ${
Original file line number Diff line number Diff line change 1
1
import { minLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const headerMinLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
4
+ const headerMinLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
5
return [
6
6
minLength ( parsed . header , value ) ,
7
7
`header must not be shorter than ${ value } characters, current length is ${
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import {Rule} from './types';
4
4
const referencesEmpty : Rule = ( parsed , when = 'never' ) => {
5
5
const negated = when === 'always' ;
6
6
const notEmpty = parsed . references . length > 0 ;
7
+
7
8
return [
8
9
negated ? ! notEmpty : notEmpty ,
9
10
message ( [ 'references' , negated ? 'must' : 'may not' , 'be empty' ] )
Original file line number Diff line number Diff line change @@ -9,9 +9,7 @@ const scopeCase: Rule<ensure.TargetCaseType | ensure.TargetCaseType[]> = (
9
9
when = 'always' ,
10
10
value = [ ]
11
11
) => {
12
- const { scope} = parsed ;
13
-
14
- if ( ! scope ) {
12
+ if ( ! parsed . scope ) {
15
13
return [ true ] ;
16
14
}
17
15
@@ -28,7 +26,7 @@ const scopeCase: Rule<ensure.TargetCaseType | ensure.TargetCaseType[]> = (
28
26
// Scopes may contain slash-delimiters to separate them and mark them as individual segments.
29
27
// This means that each of these segments should be tested separately with `ensure`.
30
28
const delimiters = / ( \/ | \\ ) / g;
31
- const scopeSegments = scope . split ( delimiters ) ;
29
+ const scopeSegments = parsed . scope . split ( delimiters ) ;
32
30
33
31
const result = checks . some ( check => {
34
32
const r = scopeSegments . every (
Original file line number Diff line number Diff line change 1
1
import { maxLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const scopeMaxLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
5
- const input = parsed . scope ;
6
-
7
- if ( ! input ) {
4
+ const scopeMaxLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
+ if ( ! parsed . scope ) {
8
6
return [ true ] ;
9
7
}
10
8
11
9
return [
12
- maxLength ( input , value ) ,
10
+ maxLength ( parsed . scope , value ) ,
13
11
`scope must not be longer than ${ value } characters`
14
12
] ;
15
13
} ;
Original file line number Diff line number Diff line change 1
1
import { minLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const scopeMinLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
5
- const input = parsed . scope ;
6
- if ( ! input ) {
4
+ const scopeMinLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
+ if ( ! parsed . scope ) {
7
6
return [ true ] ;
8
7
}
8
+
9
9
return [
10
- minLength ( input , value ) ,
10
+ minLength ( parsed . scope , value ) ,
11
11
`scope must not be shorter than ${ value } characters`
12
12
] ;
13
13
} ;
Original file line number Diff line number Diff line change @@ -6,14 +6,12 @@ const subjectFullStop: Rule<string> = (
6
6
when = 'always' ,
7
7
value = '.'
8
8
) => {
9
- const input = parsed . subject ;
10
-
11
- if ( ! input ) {
9
+ if ( ! parsed . subject ) {
12
10
return [ true ] ;
13
11
}
14
12
15
13
const negated = when === 'never' ;
16
- const hasStop = input [ input . length - 1 ] === value ;
14
+ const hasStop = parsed . subject [ parsed . subject . length - 1 ] === value ;
17
15
18
16
return [
19
17
negated ? ! hasStop : hasStop ,
Original file line number Diff line number Diff line change 1
1
import { maxLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const subjectMaxLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
5
- const input = parsed . subject ;
6
-
7
- if ( ! input ) {
4
+ const subjectMaxLength : Rule < number > = (
5
+ parsed ,
6
+ when = undefined ,
7
+ value = 0
8
+ ) => {
9
+ if ( ! parsed . subject ) {
8
10
return [ true ] ;
9
11
}
10
12
11
13
return [
12
- maxLength ( input , value ) ,
14
+ maxLength ( parsed . subject , value ) ,
13
15
`subject must not be longer than ${ value } characters`
14
16
] ;
15
17
} ;
Original file line number Diff line number Diff line change 1
1
import { minLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const subjectMinLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
5
- const input = parsed . subject ;
6
- if ( ! input ) {
4
+ const subjectMinLength : Rule < number > = (
5
+ parsed ,
6
+ when = undefined ,
7
+ value = 0
8
+ ) => {
9
+ if ( ! parsed . subject ) {
7
10
return [ true ] ;
8
11
}
12
+
9
13
return [
10
- minLength ( input , value ) ,
14
+ minLength ( parsed . subject , value ) ,
11
15
`subject must not be shorter than ${ value } characters`
12
16
] ;
13
17
} ;
Original file line number Diff line number Diff line change @@ -9,9 +9,7 @@ const typeCase: Rule<ensure.TargetCaseType | ensure.TargetCaseType[]> = (
9
9
when = 'always' ,
10
10
value = [ ]
11
11
) => {
12
- const { type} = parsed ;
13
-
14
- if ( ! type ) {
12
+ if ( ! parsed . type ) {
15
13
return [ true ] ;
16
14
}
17
15
@@ -26,7 +24,7 @@ const typeCase: Rule<ensure.TargetCaseType | ensure.TargetCaseType[]> = (
26
24
} ) ;
27
25
28
26
const result = checks . some ( check => {
29
- const r = ensure . case ( type , check . case ) ;
27
+ const r = ensure . case ( parsed . type ! , check . case ) ;
30
28
return negated ( check . when ) ? ! r : r ;
31
29
} ) ;
32
30
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import {Rule} from './types';
5
5
const typeEmpty : Rule = ( parsed , when = 'always' ) => {
6
6
const negated = when === 'never' ;
7
7
const notEmpty = ensure . notEmpty ( parsed . type || '' ) ;
8
+
8
9
return [
9
10
negated ? notEmpty : ! notEmpty ,
10
11
message ( [ 'type' , negated ? 'may not' : 'must' , 'be empty' ] )
Original file line number Diff line number Diff line change @@ -3,14 +3,12 @@ import message from '@commitlint/message';
3
3
import { Rule } from './types' ;
4
4
5
5
const typeEnum : Rule < string [ ] > = ( parsed , when = 'always' , value = [ ] ) => {
6
- const { type : input } = parsed ;
7
-
8
- if ( ! input ) {
6
+ if ( ! parsed . type ) {
9
7
return [ true ] ;
10
8
}
11
9
12
10
const negated = when === 'never' ;
13
- const result = ensure . enum ( input , value ) ;
11
+ const result = ensure . enum ( parsed . type , value ) ;
14
12
15
13
return [
16
14
negated ? ! result : result ,
Original file line number Diff line number Diff line change 1
1
import { maxLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const typeMaxLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
5
- const input = parsed . type ;
6
-
7
- if ( ! input ) {
4
+ const typeMaxLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
+ if ( ! parsed . type ) {
8
6
return [ true ] ;
9
7
}
10
8
11
9
return [
12
- maxLength ( input , value ) ,
10
+ maxLength ( parsed . type , value ) ,
13
11
`type must not be longer than ${ value } characters`
14
12
] ;
15
13
} ;
Original file line number Diff line number Diff line change 1
1
import { minLength } from '@commitlint/ensure' ;
2
2
import { Rule } from './types' ;
3
3
4
- const typeMinLength : Rule < number > = ( parsed , when = 'always' , value = 0 ) => {
5
- const input = parsed . type ;
6
- if ( ! input ) {
4
+ const typeMinLength : Rule < number > = ( parsed , when = undefined , value = 0 ) => {
5
+ if ( ! parsed . type ) {
7
6
return [ true ] ;
8
7
}
8
+
9
9
return [
10
- minLength ( input , value ) ,
10
+ minLength ( parsed . type , value ) ,
11
11
`type must not be shorter than ${ value } characters`
12
12
] ;
13
13
} ;
You can’t perform that action at this time.
0 commit comments