@@ -19,13 +19,30 @@ var Checker = (function () {
1919 var start = new Date ( ) . getTime ( ) ;
2020 var parsed = ts . parseJsonConfigFileContent ( this . tsConfig , parseConfigHost , options . basePath || '.' , null ) ;
2121 this . program = ts . createProgram ( parsed . fileNames , parsed . options , null , this . program ) ;
22- this . diagnostics = ts . getPreEmitDiagnostics ( this . program ) ;
22+ this . diagnostics = [ ] ;
23+ var optionsErrors = this . program . getOptionsDiagnostics ( ) . map ( function ( obj ) {
24+ obj . _type = 'options' ;
25+ return obj ;
26+ } ) ;
27+ this . diagnostics = this . diagnostics . concat ( optionsErrors ) ;
28+ var globalErrors = this . program . getGlobalDiagnostics ( ) . map ( function ( obj ) {
29+ obj . _type = 'global' ;
30+ return obj ;
31+ } ) ;
32+ this . diagnostics = this . diagnostics . concat ( globalErrors ) ;
33+ var syntacticErrors = this . program . getSyntacticDiagnostics ( ) . map ( function ( obj ) {
34+ obj . _type = 'syntactic' ;
35+ return obj ;
36+ } ) ;
37+ this . diagnostics = this . diagnostics . concat ( syntacticErrors ) ;
38+ var semanticErrors = this . program . getSemanticDiagnostics ( ) . map ( function ( obj ) {
39+ obj . _type = 'semantic' ;
40+ return obj ;
41+ } ) ;
42+ this . diagnostics = this . diagnostics . concat ( semanticErrors ) ;
2343 this . lintResults = [ ] ;
2444 if ( options . tsLint ) {
2545 var fullPath = path . resolve ( this . options . basePath , options . tsLint ) ;
26- var fileName = path . basename ( fullPath ) ;
27- var basePath = path . dirname ( fullPath ) ;
28- console . log ( "f:" + fileName + " base:" + basePath ) ;
2946 this . files = tslint . Linter . getFileNames ( this . program ) ;
3047 var config_1 = tslint . Configuration . findConfiguration ( fullPath , this . options . basePath ) . results ;
3148 this . lintResults = this . files . map ( function ( file ) {
@@ -55,14 +72,14 @@ var Checker = (function () {
5572 fileName : failure . fileName ,
5673 line : failure . startPosition . lineAndCharacter . line ,
5774 char : failure . startPosition . lineAndCharacter . character ,
58- ruleSeverity : failure . ruleSeverity ,
75+ ruleSeverity : failure . ruleSeverity . charAt ( 0 ) . toUpperCase ( ) + failure . ruleSeverity . slice ( 1 ) ,
5976 ruleName : failure . ruleName ,
6077 failure : failure . failure
6178 } ;
6279 var message = chalk . red ( '└── ' ) ;
63- message += chalk . red ( r . fileName + ": (" + ( r . line + 1 ) + ": " + ( r . char + 1 ) + "): " ) ;
64- message += chalk . white ( r . ruleSeverity ) ;
65- message += chalk . white ( " TSLint: \"" + r . ruleName + "\": " ) ;
80+ message += chalk [ options . yellowOnLint ? 'yellow' : ' red' ] ( r . fileName + " (" + ( r . line + 1 ) + ", " + ( r . char + 1 ) + ") " ) ;
81+ message += chalk . white ( "(" + r . ruleSeverity + ":" ) ;
82+ message += chalk . white ( r . ruleName + ") " ) ;
6683 message += ' ' + r . failure ;
6784 return message ;
6885 } ) ;
@@ -83,11 +100,28 @@ var Checker = (function () {
83100 if ( diagnostics . length > 0 ) {
84101 messages = diagnostics . map ( function ( diag ) {
85102 var message = chalk . red ( '└── ' ) ;
103+ var color ;
104+ switch ( diag . _type ) {
105+ case 'options' :
106+ color = options . yellowOnOptions ? 'yellow' : 'red' ;
107+ break ;
108+ case 'global' :
109+ color = options . yellowOnGlobal ? 'yellow' : 'red' ;
110+ break ;
111+ case 'syntactic' :
112+ color = options . yellowOnSyntactic ? 'yellow' : 'red' ;
113+ break ;
114+ case 'semantic' :
115+ color = options . yellowOnSemantic ? 'yellow' : 'red' ;
116+ break ;
117+ default :
118+ color = 'red' ;
119+ }
86120 if ( diag . file ) {
87121 var _a = diag . file . getLineAndCharacterOfPosition ( diag . start ) , line = _a . line , character = _a . character ;
88- message += chalk . red ( diag . file . fileName + ": (" + ( line + 1 ) + ": " + ( character + 1 ) + "): " ) ;
89- message += chalk . white ( ts . DiagnosticCategory [ diag . category ] ) ;
90- message += chalk . white ( " TS" + diag . code + ": " ) ;
122+ message += chalk [ color ] ( diag . file . fileName + " (" + ( line + 1 ) + ", " + ( character + 1 ) + ") " ) ;
123+ message += chalk . white ( "(" + ts . DiagnosticCategory [ diag . category ] + ":" ) ;
124+ message += chalk . white ( "TS" + diag . code + ") " ) ;
91125 }
92126 message += ' ' + ts . flattenDiagnosticMessageText ( diag . messageText , END_LINE ) ;
93127 return message ;
@@ -96,6 +130,12 @@ var Checker = (function () {
96130 var x = messages . concat ( lintResults ) ;
97131 write ( x . join ( '\n' ) ) ;
98132 }
133+ else {
134+ if ( lintResults . length > 0 ) {
135+ lintResults . unshift ( chalk . underline ( END_LINE + "File errors" ) + chalk . white ( ':' ) ) ;
136+ write ( lintResults . join ( '\n' ) ) ;
137+ }
138+ }
99139 var optionsErrors = program . getOptionsDiagnostics ( ) . length ;
100140 var globalErrors = program . getGlobalDiagnostics ( ) . length ;
101141 var syntacticErrors = program . getSyntacticDiagnostics ( ) . length ;
@@ -105,11 +145,11 @@ var Checker = (function () {
105145 write ( chalk . underline ( "" + END_LINE + END_LINE + "Errors" ) +
106146 chalk . white ( ":" + totals + END_LINE ) ) ;
107147 if ( totals ) {
108- write ( chalk [ optionsErrors ? 'red' : 'white' ] ( "\u2514\u2500\u2500 Options: " + optionsErrors + END_LINE ) ) ;
109- write ( chalk [ globalErrors ? 'red' : 'white' ] ( "\u2514\u2500\u2500 Global: " + globalErrors + END_LINE ) ) ;
110- write ( chalk [ syntacticErrors ? 'red' : 'white' ] ( "\u2514\u2500\u2500 Syntactic: " + syntacticErrors + END_LINE ) ) ;
111- write ( chalk [ semanticErrors ? 'red' : 'white' ] ( "\u2514\u2500\u2500 Semantic: " + semanticErrors + END_LINE ) ) ;
112- write ( chalk [ tsLintErrors ? 'red' : 'white' ] ( "\u2514\u2500\u2500 TsLint: " + tsLintErrors + END_LINE + END_LINE ) ) ;
148+ write ( chalk [ optionsErrors ? options . yellowOnOptions ? 'yellow' : 'red' : 'white' ] ( "\u2514\u2500\u2500 Options: " + optionsErrors + END_LINE ) ) ;
149+ write ( chalk [ globalErrors ? options . yellowOnGlobal ? 'yellow' : 'red' : 'white' ] ( "\u2514\u2500\u2500 Global: " + globalErrors + END_LINE ) ) ;
150+ write ( chalk [ syntacticErrors ? options . yellowOnSyntactic ? 'yellow' : 'red' : 'white' ] ( "\u2514\u2500\u2500 Syntactic: " + syntacticErrors + END_LINE ) ) ;
151+ write ( chalk [ semanticErrors ? options . yellowOnSemantic ? 'yellow' : 'red' : 'white' ] ( "\u2514\u2500\u2500 Semantic: " + semanticErrors + END_LINE ) ) ;
152+ write ( chalk [ tsLintErrors ? options . yellowOnLint ? 'yellow' : 'red' : 'white' ] ( "\u2514\u2500\u2500 TsLint: " + tsLintErrors + END_LINE + END_LINE ) ) ;
113153 }
114154 write ( chalk . grey ( "Typechecking time: " + this . elapsed + "ms" + END_LINE ) ) ;
115155 switch ( true ) {
0 commit comments