@@ -16,55 +16,56 @@ const STAGED = true;
16
16
* them from being processed in the first place, as a performance optimization.
17
17
* This is increasingly useful the more files there are in the repository.
18
18
*/
19
- const getPreProcessor = ( staged = false ) => (
20
- text : string ,
21
- filename : string
22
- ) => {
23
- const shouldBeProcessed = getDiffFileList ( staged ) . includes ( filename ) ;
19
+ const getPreProcessor =
20
+ ( staged = false ) =>
21
+ ( text : string , filename : string ) => {
22
+ const shouldBeProcessed = getDiffFileList ( staged ) . includes ( filename ) ;
24
23
25
- return shouldBeProcessed ? [ text ] : [ ] ;
26
- } ;
24
+ return shouldBeProcessed ? [ text ] : [ ] ;
25
+ } ;
27
26
28
27
const isLineWithinRange = ( line : number ) => ( range : Range ) =>
29
28
range . isWithinRange ( line ) ;
30
29
31
- const getPostProcessor = ( staged = false ) => (
32
- messages : Linter . LintMessage [ ] [ ] ,
33
- filename : string
34
- ) : Linter . LintMessage [ ] => {
35
- if ( staged && ! hasCleanIndex ( filename ) ) {
36
- const fatal = true ;
37
- const message = `${ filename } has unstaged changes. Please stage or remove the changes.` ;
38
- const severity : Linter . Severity = 2 ;
39
- const fatalError : Linter . LintMessage = {
40
- fatal,
41
- message,
42
- severity,
43
- column : 0 ,
44
- line : 0 ,
45
- ruleId : null ,
46
- } ;
47
- return [ fatalError ] ;
48
- }
30
+ const getPostProcessor =
31
+ ( staged = false ) =>
32
+ (
33
+ messages : Linter . LintMessage [ ] [ ] ,
34
+ filename : string
35
+ ) : Linter . LintMessage [ ] => {
36
+ if ( staged && ! hasCleanIndex ( filename ) ) {
37
+ const fatal = true ;
38
+ const message = `${ filename } has unstaged changes. Please stage or remove the changes.` ;
39
+ const severity : Linter . Severity = 2 ;
40
+ const fatalError : Linter . LintMessage = {
41
+ fatal,
42
+ message,
43
+ severity,
44
+ column : 0 ,
45
+ line : 0 ,
46
+ ruleId : null ,
47
+ } ;
48
+ return [ fatalError ] ;
49
+ }
49
50
50
- return messages
51
- . map ( ( message ) => {
52
- const filteredMessage = message . filter ( ( { fatal, line } ) => {
53
- if ( fatal === true ) {
54
- return true ;
55
- }
51
+ return messages
52
+ . map ( ( message ) => {
53
+ const filteredMessage = message . filter ( ( { fatal, line } ) => {
54
+ if ( fatal === true ) {
55
+ return true ;
56
+ }
56
57
57
- const isLineWithinSomeRange = getRangesForDiff (
58
- getDiffForFile ( filename , staged )
59
- ) . some ( isLineWithinRange ( line ) ) ;
58
+ const isLineWithinSomeRange = getRangesForDiff (
59
+ getDiffForFile ( filename , staged )
60
+ ) . some ( isLineWithinRange ( line ) ) ;
60
61
61
- return isLineWithinSomeRange ;
62
- } ) ;
62
+ return isLineWithinSomeRange ;
63
+ } ) ;
63
64
64
- return filteredMessage ;
65
- } )
66
- . reduce ( ( a , b ) => a . concat ( b ) , [ ] ) ;
67
- } ;
65
+ return filteredMessage ;
66
+ } )
67
+ . reduce ( ( a , b ) => a . concat ( b ) , [ ] ) ;
68
+ } ;
68
69
69
70
const getProcessors = ( staged = false ) => ( {
70
71
preprocess : getPreProcessor ( staged ) ,
0 commit comments