@@ -56,9 +56,11 @@ process.stdin.on('end', () => {
56
56
}
57
57
58
58
const newErrors = [ ] ;
59
+ const resolvedErrors = [ ] ;
59
60
// Walk each file to do an error comparison
60
61
for ( const [ file , errors ] of Object . entries ( compilerErrors ) ) {
61
62
let newErrs = errors ;
63
+ let resolved = [ ] ;
62
64
// Walk each file to do an error comparison
63
65
const oldFileErrors = priorStats [ file ] ;
64
66
if ( oldFileErrors && oldFileErrors . length > 0 ) {
@@ -68,30 +70,42 @@ process.stdin.on('end', () => {
68
70
// error from the states file on disk
69
71
return ! oldFileErrors . some ( err => err . message === e . message ) ;
70
72
} ) ;
73
+ resolved = oldFileErrors . filter ( e => {
74
+ return ! errors . some ( err => err . message === e . message ) ;
75
+ } ) ;
71
76
}
72
77
// Collect any newly-reported errors
73
78
newErrors . push ( ...newErrs ) ;
79
+ resolvedErrors . push ( ...resolved ) ;
74
80
}
75
81
76
- if ( ! newErrors . length ) {
77
- process . exit ( 0 ) ;
78
- }
82
+ if ( newErrors . length > 0 ) {
83
+ console . log (
84
+ chalk . red ( `${ newErrors . length } new TypeScript error(s) were introduced to the code base with your changes. \n` ) +
85
+ chalk . black . bgRed ( 'You must resolve all new TypeScript errors before merging a PR.' )
86
+ ) ;
79
87
80
- console . log (
81
- chalk . red ( `${ newErrors . length } new TypeScript error(s) were introduced to the code base with your changes. \n` ) +
82
- chalk . white . bgRed ( 'You must resolve all new TypeScript errors before merging a PR.' )
83
- ) ;
84
-
85
- newErrors . forEach ( err => {
86
- console . log ( chalk . red ( err . rawError + "\n" ) ) ;
87
- err . rawSnippet . split ( "\n" ) . forEach ( raw => {
88
- console . log ( " " + raw ) ;
88
+ newErrors . forEach ( err => {
89
+ console . log ( chalk . red ( err . rawError + "\n" ) ) ;
90
+ err . rawSnippet . split ( "\n" ) . forEach ( raw => {
91
+ console . log ( " " + raw ) ;
92
+ } ) ;
89
93
} ) ;
90
- } ) ;
91
94
92
- console . log (
93
- "\n" +
94
- chalk . red ( `${ newErrors . length } new TypeScript error(s) were introduced to the code base with your changes. \n` ) +
95
- chalk . white . bgRed ( 'You must resolve all new TypeScript errors before merging a PR.' )
96
- ) ;
95
+ console . log (
96
+ "\n" +
97
+ chalk . red ( `${ newErrors . length } new TypeScript error(s) were introduced to the code base with your changes. \n` ) +
98
+ chalk . black . bgRed ( 'You must resolve all new TypeScript errors before merging a PR.' )
99
+ ) ;
100
+ }
101
+
102
+ if ( resolvedErrors . length > 0 ) {
103
+ console . log (
104
+ chalk . black . bgGreen ( `Looks like you've fixed ~${ resolvedErrors . length } of our existing error(s)! Here's a cookie to celebrate 🍪` )
105
+ ) ;
106
+ }
107
+
108
+ if ( ! newErrors . length ) {
109
+ process . exit ( 0 ) ;
110
+ }
97
111
} ) ;
0 commit comments