stylelint / vscode-stylelint

The official Visual Studio Code extension for Stylelint
https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint
MIT License
315 stars 29 forks source link

VSCode extension does not respect folder settings! #484

Open mctrafik opened 10 months ago

mctrafik commented 10 months ago

What minimal example or steps are needed to reproduce the bug?

I have the following repositories in my VSCode workspace:

workspace/
- marketing-web/
--- .stylelintrc.js
- web-platform/
--- .vscode/
----- settings.json (specifies  `"stylelint.configFile": "js/config/.stylelintrc.js"` )
--- js/
---- config/
------ .stylelintrc.js

Both are loaded in vs-code in the same workspace because they share packages and I need to compile both and link them together when coding. As you can see the location of stylelintrc is in different folders.

I have no stylelint extension config in my user or in my workspace settings. But I do have settings in the web-platform folder.

Screenshot 2023-11-18 at 11 38 35 AM

The issue is that stylelint extension crashes when I work in web-platform folder with:

no such file or directory, open `Users/../marketing-web/js/config/.stylelintrc.js`

Which is true.. that file doesn't exit, but the extension shouldn't be looking for it.

Screenshot 2023-11-18 at 11 39 11 AM

My guess is that your extension doesn't determine what the current workspace folder the user is in, and uses the first one, always (which is wrong).

What minimal configuration is needed to reproduce the bug?

N/A

How did you run Stylelint?

Through vs-code extension.

Which Stylelint-related dependencies are you using?

vscode extension 1.3.0

"stylelint": "^15.11.0", "stylelint-config-recommended": "^13.0.0", "stylelint-config-styled-components": "^0.1.1",

What did you expect to happen?

I expect it to search in the correct workspace folder for the stylelint rc path.

What actually happened?

It searched for the config in the wrong workspace folder.

Do you have a proposal to fix the bug?

N/A

mctrafik commented 10 months ago

Screenshot 2023-11-18 at 11 43 45 AM

I filed a similar bug with another extension and just in case it's not obvious, I have 3 folders in my workspace. I'm working in web-platform and the setting is for that folder, but it's being applied to marketing-web, which is a different folder and it doesn't have the override! So the root stylelintrc.js should be found.

pogz commented 10 months ago

I ran into a similar issue with a multi-root workspace. It looks like this extension may not have been updated to support the multi-root workspace APIs:

https://code.visualstudio.com/docs/editor/multi-root-workspaces

Here is the specific documentation on the changes required for language servers:

https://github.com/microsoft/vscode/wiki/Adopting-Multi-Root-Workspace-APIs#language-client--language-server

The fallback logic appears to be that it will treat the first folder/package in the workspace as the "root", which breaks relative paths used in other packages within the workspace. The package in my workspace using this extension is not the first, so the relative paths in the .vscode/settings.json file and my .stylelintrc.json attempt to resolve against the first package folder and throw an exception, breaking all style linting.

gian1200 commented 3 weeks ago

With v1.4.0, this is still an issue with the extension.

I ran into a similar issue with a multi-root workspace. It looks like this extension may not have been updated to support the multi-root workspace APIs

The fallback logic appears to be that it will treat the first folder/package in the workspace as the "root",

This is key.