fi3ework / vite-plugin-checker

💬 Vite plugin that provide checks of TypeScript, ESLint, vue-tsc, Stylelint and more.
https://vite-plugin-checker.netlify.app
MIT License
1k stars 87 forks source link

Empty `ERROR` message #238

Open denchiklut opened 1 year ago

denchiklut commented 1 year ago

Describe the bug

When typescript check option is true always getting this message

Screenshot 2023-05-24 at 2 00 30 PM
 ERROR 
[TypeScript] Found 0 errors. Watching for file changes.

I tried to debug it and added log with *** action to the main.js plugin source file.

Screenshot 2023-05-24 at 1 48 14 PM

And since this action treaded as an Error on line 182 we just added prefix ERROR.

Screenshot 2023-05-24 at 1 49 26 PM

Reproduction

in vite config

import checker from 'vite-plugin-checker'
...
plugins: [
    checker({ typescript: true })
]

Expected behavior

Action { type: 'console', payload: '\n[TypeScript] Found 0 errors. Watching for file changes.' } should't be logged as an Error

System Info

System:
    OS: macOS 13.3.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 1.87 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.14.0/bin/yarn
    npm: 9.3.1 - ~/.nvm/versions/node/v18.14.0/bin/npm
  Browsers:
    Chrome: 113.0.5672.126
    Safari: 16.4
  npmPackages:
    vite-plugin-checker: 0.6.0 => 0.6.0


### Additional context

_No response_

### Validations

- [X] Read the [docs](https://github.com/fi3ework/vite-plugin-checker#readme).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
jonocairns commented 1 year ago

Any progress on this? Seems like the only option is to revert to 0.4.9

james-yeoman commented 1 year ago

Actually, the change seems to have been introduced in 0.5.6

ferm10n commented 1 year ago

Error: no errors were found. image

IM GONNA REEEE

oniice commented 11 months ago

Happening for me with nuxt 3.8.2 on a fresh install/setup

onkar-rentomojo commented 11 months ago

Same for me? Any workaround for this?

ibockowsky commented 10 months ago

Still an issue

image
james-yeoman commented 10 months ago

Actually, the change seems to have been introduced in 0.5.6

I figured out where the problem got introduced, but there's been no addressing of it thus far

james-yeoman commented 10 months ago

This line looks like it might be the root of the issue. https://github.com/fi3ework/vite-plugin-checker/commit/8dd49159bddd7e3e23dfa479323322808094d8b9#diff-7c457428fc11687ac503085166d754dc2dbdaa3df69069d3027272bda149ba5cR189

I found that while trawling through the diff between v0.5.5 and 0.5.6 https://github.com/fi3ework/vite-plugin-checker/compare/vite-plugin-checker%400.5.5...vite-plugin-checker%400.5.6

kristremblay commented 10 months ago

@james-yeoman I'm seeing the same. Unsure why it would log if Checker.logger is empty, maybe an oversight?

james-yeoman commented 8 months ago

So the logger comes from Vite itself. I wonder why this plugin isn't receiving the logger from Vite... https://github.com/fi3ework/vite-plugin-checker/commit/8dd49159bddd7e3e23dfa479323322808094d8b9

james-yeoman commented 8 months ago

Ok, so vite-plugin-checker is receiving the logger from vite, I'm just a dunce...

The actual problem, is that Checker.logger is never populated, and the colouring of diagnostics and summaries are already handled by diagnosticToTerminalLog and composeCheckerSummary in vite-plugin-checker/src/logger.ts.

There's currently no way of differentiating between an error, a warning, and a checker summary.

This is beyond what I can justify spending time on during work, but hopefully my findings help someone who can spend more time on open source to fix this

james-yeoman commented 8 months ago

As a workaround, I've got a fork that I've added a bypass to in order to avoid erroring on an empty summary. It's not the cleanest, but it allows me to adopt the ESLint Flat Config without too much problem

james-yeoman commented 8 months ago

:/ I use yarn and so can't reference the fork since this plugin uses pnpm...

guess I'm back to using yarn patches instead...

FeatureSpitter commented 3 months ago

So, no solution to this so far? lol

marpro200 commented 2 months ago

Hey so I had the same problem and I managed to implement a workaround:

Vite offers the functionality to customize the logs: https://vitejs.dev/config/shared-options.html#customlogger

So I converted some errors from vite-plugin-checker to an info:

import { defineConfig, createLogger } from "vite";
import os from 'node:os'

const logger = createLogger()
const loggerErr = logger.error

logger.error = (msg, options) => {
    if (msg.match(/.*\[ESLint\] Found 0 error and 0 warning.*/)) {
        logger.info(msg, options)
        return
    }

    if (msg.match(/.*\[TypeScript\] Found 0 errors. Watching for file changes.*/)) {
        logger.info(msg.replace(os.EOL, ""), options)
        return
    }

    loggerErr(msg, options)
}

export default defineConfig({
    customLogger: logger
});

With those changes my output looks like this: image

Hope this helps someone.

SoCuul commented 4 weeks ago

@fi3ework could this patch be merged into this repo? still happening on the latest version