ModyQyW / vite-plugin-stylelint

🚨 Stylelint plugin for Vite.
MIT License
23 stars 1 forks source link

Passing `context` to `lintFiles` when enable `chokidar` breaks the build #51

Closed ModyQyW closed 1 month ago

ModyQyW commented 1 year ago

I apologize that I may not have expressed my opinion correctly and completely before. And sorry I am late in response.

Normally, enabling lintInWorker would only show errors and warnings in the console, but otherwise in the console and the browser.

Now, with chokidar enabled and lintInWorker disabled, I can't pass the context to the function (see https://github.com/ModyQyW/vite-plugin-stylelint/blob/v5.1.1/src/index.ts#L78-L98 comments) because it causes an error and just quits the Vite process. This leads to the problem mentioned in https://github.com/nuxt-modules/stylelint/issues/89, where the plugin only displays error and warning messages in the console, not in the browser.

I don't think adding an option called failOnError solves this problem. To fix this, we need to pass the context and avoid the error.

I think we only need to quit the process if the lintOnStart option is enabled and an error is checked, which would request the user to deal with the error that exists first to avoid caching issues ⬇️, which is exactly what this plugin currently behaves like.

image

Originally posted by @ModyQyW in https://github.com/ModyQyW/vite-plugin-stylelint/issues/50#issuecomment-1691082257

ModyQyW commented 4 months ago

I can confirm that it is caused by chokidar watch callback.

ModyQyW commented 1 month ago

I'm hoping that vite-plugin-stylelint 6.0.0-beta.0 will address the root cause of this issue and would like to gather feedback on it before the official release.

On @nuxtjs/stylelint-module 5.2.0, you can disable lintDirtyOnly to check all style files, including deep-imported files of course, but there is some performance loss.