File tree Expand file tree Collapse file tree 9 files changed +24
-10
lines changed
packages/vite-plugin-checker/src Expand file tree Collapse file tree 9 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ const createDiagnostic: CreateDiagnostic<'biome'> = (pluginConfig) => {
5858
5959 if ( terminal ) {
6060 for ( const d of diagnostics ) {
61- consoleLog ( diagnosticToTerminalLog ( d , 'Biome' ) )
61+ consoleLog ( diagnosticToTerminalLog ( d , 'Biome' ) , 'info' )
6262 }
6363
6464 const errorCount = diagnostics . filter (
@@ -67,7 +67,10 @@ const createDiagnostic: CreateDiagnostic<'biome'> = (pluginConfig) => {
6767 const warningCount = diagnostics . filter (
6868 ( d ) => d . level === DiagnosticLevel . Warning ,
6969 ) . length
70- consoleLog ( composeCheckerSummary ( 'Biome' , errorCount , warningCount ) )
70+ consoleLog (
71+ composeCheckerSummary ( 'Biome' , errorCount , warningCount ) ,
72+ errorCount ? 'error' : warningCount ? 'warn' : 'info' ,
73+ )
7174 }
7275
7376 if ( overlay ) {
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ const createDiagnostic: CreateDiagnostic<'eslint'> = (pluginConfig) => {
9191
9292 if ( terminal ) {
9393 for ( const d of diagnostics ) {
94- consoleLog ( diagnosticToTerminalLog ( d , 'ESLint' ) )
94+ consoleLog ( diagnosticToTerminalLog ( d , 'ESLint' ) , 'info' )
9595 }
9696
9797 const errorCount = diagnostics . filter (
@@ -100,7 +100,10 @@ const createDiagnostic: CreateDiagnostic<'eslint'> = (pluginConfig) => {
100100 const warningCount = diagnostics . filter (
101101 ( d ) => d . level === DiagnosticLevel . Warning ,
102102 ) . length
103- consoleLog ( composeCheckerSummary ( 'ESLint' , errorCount , warningCount ) )
103+ consoleLog (
104+ composeCheckerSummary ( 'ESLint' , errorCount , warningCount ) ,
105+ errorCount ? 'error' : warningCount ? 'warn' : 'info' ,
106+ )
104107 }
105108
106109 if ( overlay ) {
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ const createDiagnostic: CreateDiagnostic<'stylelint'> = (pluginConfig) => {
6363
6464 if ( terminal ) {
6565 for ( const d of diagnostics ) {
66- consoleLog ( diagnosticToTerminalLog ( d , 'Stylelint' ) )
66+ consoleLog ( diagnosticToTerminalLog ( d , 'Stylelint' ) , 'info' )
6767 }
6868
6969 const errorCount = diagnostics . filter (
@@ -74,6 +74,7 @@ const createDiagnostic: CreateDiagnostic<'stylelint'> = (pluginConfig) => {
7474 ) . length
7575 consoleLog (
7676 composeCheckerSummary ( 'Stylelint' , errorCount , warningCount ) ,
77+ errorCount ? 'error' : warningCount ? 'warn' : 'info' ,
7778 )
7879 }
7980
Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ const createDiagnostic: CreateDiagnostic<'typescript'> = (pluginConfig) => {
124124 diagnostic . messageText . toString ( ) ,
125125 ) ,
126126 ) ,
127+ errorCount ? 'error' : 'info' ,
127128 )
128129 }
129130 } )
Original file line number Diff line number Diff line change @@ -38,7 +38,10 @@ export const createDiagnostic: CreateDiagnostic<'vls'> = (pluginConfig) => {
3838 ( errorCount , warningCount ) => {
3939 if ( ! terminal ) return
4040
41- consoleLog ( composeCheckerSummary ( 'VLS' , errorCount , warningCount ) )
41+ consoleLog (
42+ composeCheckerSummary ( 'VLS' , errorCount , warningCount ) ,
43+ errorCount ? 'error' : warningCount ? 'warn' : 'info' ,
44+ )
4245 }
4346
4447 const onDispatchDiagnostics : DiagnosticOptions [ 'onDispatchDiagnostics' ] =
@@ -58,6 +61,7 @@ export const createDiagnostic: CreateDiagnostic<'vls'> = (pluginConfig) => {
5861 normalized
5962 . map ( ( d ) => diagnosticToTerminalLog ( d , 'VLS' ) )
6063 . join ( os . EOL ) ,
64+ 'info' ,
6165 )
6266 }
6367 }
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ const createDiagnostic: CreateDiagnostic<'vueTsc'> = (pluginConfig) => {
122122
123123 // TODO: only macOS will report multiple times for same result
124124 prevLogChunk = logChunk
125- consoleLog ( logChunk )
125+ consoleLog ( logChunk , errorCount ? 'error' : 'info' )
126126 }
127127 } )
128128 }
Original file line number Diff line number Diff line change @@ -419,12 +419,13 @@ export function ensureCall(callback: CallableFunction) {
419419 } )
420420}
421421
422- export function consoleLog ( value : string ) {
422+ export function consoleLog ( value : string , level : 'info' | 'warn' | 'error' ) {
423423 if ( isMainThread ) {
424- console . log ( value )
424+ console [ level ] ( value )
425425 } else {
426426 parentPort ?. postMessage ( {
427427 type : ACTION_TYPES . console ,
428+ level : level ,
428429 payload : value ,
429430 } )
430431 }
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
201201 // for test injection and customize logger in the future
202202 Checker . log ( action )
203203 } else {
204- logger ! . error ( action . payload )
204+ logger ! [ action . level ] ( action . payload )
205205 }
206206 }
207207 } )
Original file line number Diff line number Diff line change @@ -260,6 +260,7 @@ export interface ConfigureServerAction extends AbstractAction {
260260
261261export interface ConsoleAction extends AbstractAction {
262262 type : ACTION_TYPES . console
263+ level : 'info' | 'warn' | 'error'
263264 payload : string
264265}
265266
You can’t perform that action at this time.
0 commit comments