Closed ModyQyW closed 1 year ago
I did some digging.
First, I add two rows in my plugin locally. So my plugin will print something I want to see.
Then, I update the vue example package.json
and install.
Also update vite.plugin.ts
.
Import app.scss
.
Run dev. And I get nothing error. But I expected app.scss
errors.
No errors in page and console.
No errors in terminal. And I notice that no app.scss
is logged.
Visit http://localhost:3001/__inspect/ and I found these.
Vite DOES compiles app.scss
, but in an unexpected way. The plugin expects to get app.scss
in the transform
hook so stylelint can work.
No idea how to fix for now. Any PR or any idea will be appreciated. Thanks!
Perhaps this actually is caused by this Vite issue: https://github.com/vitejs/vite/issues/8224
The comments state that downgrading your Vite version might help but that obviously doesn't(and perhaps can't) fix the issue in this plugin
I am not sure. I think in this case, the file is compiled by postcss
and sass
so app.scss
never comes to the transform
hook.
There is a new option called lintOnStart
in v3.0.0, which may be helpful for such situations. Please have a try.
There is a new option called
lintOnStart
in v3.0.0, which may be helpful for such situations. Please have a try.
Thanks for the update! This gives you an error whenever you start the server(When you fix the error whilst its running the error doesn't clear so you'll have to restart);
It doesn't give lint errors when the devServer is already running though.
It doesn't give lint errors when the devServer is already running though.
Yes. I can't find a neat way to hack into. PR welcome :)
Six months have passed, and I've finally come up with an idea.
Since the transform
hook can't handle files introduced by @import
, why don't we jump out of the transform
hook?
v3.3.0 introduces the chokidar
option, which allows you to use chokidar
as a listener so that stylelint
can handle files introduced by @import
! This is a new option, please try it out and give me feedback ❤
I am closing this. Feel free to open another issue if you are facing problems using chokidar
option. :)
Thanks for sticking with this issue, it's much appreciated. I've had the chance to test this out. I didnt some searching and made some comments here that do not seem to belong to the stylelintConfig so I'm starting over with my findings:
Stylelinting scss files that are imported seem to work but it has some issues:
fix: true
doesn't work (anymore) in both Vue files and scss files. Having cache
true/false doesn't seem to matter.The second problem has been fixed and will be released in v3.3.2.
Digging he first problem...
Works like a charm! This makes triggering errors a lot harder which makes it perfectly workable for me. Although I do think fixing the first problem is still a big win for everyone.
Should be fine in v3.3.3. But I find another problem in https://github.com/ModyQyW/vite-plugin-stylelint/issues/27.
Importing a test.scss in that scope doesn't lint that test.scss still (it does compile!)
index.vue:
test.scss:
test.scss DOES compile; but does NOT lint
Bare in mind: Running my linter via NPM does pickup the error: script in package.json:
"lint:css": "stylelint ./**/*.{vue,scss} --fix",
Originally posted by @timenengwerda in https://github.com/ModyQyW/vite-plugin-stylelint/issues/8#issuecomment-1131382030