vscode-stylelint: [Bug]: Format Document not working ((still ask about "postcss-scss", and use the "customSyntax" option))
How did you encounter this bug?
I tried to use Format Document but it doesn’t work.
Note: Fix all stylelint autofixable works all the time
My package.json:
{
"private": true,
"devDependencies": {
"autoprefixer": "latest",
"bootstrap": "4.6.1",
"nodemon": "latest",
"postcss": "latest",
"postcss-cli": "latest",
"postcss-scss": "^4.0.2",
"sass": "^1.43.4",
"stylelint": "latest",
"stylelint-config-recommended": "latest",
"stylelint-config-sass-guidelines": "latest",
"stylelint-config-standard": "latest",
"stylelint-config-standard-scss": "^2.0.1",
"svgo": "latest"
}
}
My .stylelintrc:
{
"extends": [
"stylelint-config-standard-scss"
],
"customSyntax": "postcss-scss",
"rules": {
"indentation": "tab",
"max-nesting-depth": null,
"selector-max-compound-selectors": null,
"selector-no-qualifying-type": null,
"selector-class-pattern": null,
"selector-max-id": null
}
}
Code Snippet
// ------- Main navigation -------
.cssext-main-menu {
> ul > li > a {
font-weight: bold;
text-transform: uppercase;
}
.dropdown-menu {
border: 0;
margin-left: 15px;
margin-right: 15px;
}
@media (min-width: 768px) {
> ul > li {
border-right: 1px dotted #a3a3a3;
}
> ul > li:last-child {
border-right: 0;
}
.navbar-nav .nav-link:first-child, {
padding-left: 0;
}
.navbar-nav .nav-link:last-child, {
padding-right: 0;
}
.dropdown-menu {
border-radius: 0;
margin-left: -30px;
margin-right: unset;
margin-top: 16px;
padding: 7px;
}
.dropdown-menu.show {
display: grid;
grid-auto-flow: column;
grid-template-rows: 1fr 1fr 1fr;
}
.dropdown-item {
text-align: left;
&:active {
background-color: #f8f9fa;
color: #535353;
}
}
.dropdown-menu .dropdown-item {
text-align: left;
}
.dropdown-item::before {
background: #dc3545;
content: '';
display: inline-block;
height: 8px;
margin-bottom: 1px;
margin-right: 8px;
width: 8px;
}
.dropdown::after {
background-color: rgba(0, 0, 0, 0.7);
bottom: 0;
content: '';
left: 0;
opacity: 0;
pointer-events: none;
right: 0;
top: 0;
transition: opacity 0.15s ease-in-out;
visibility: hidden;
}
.dropdown.show .nav-link {
position: relative;
z-index: 12;
}
.dropdown.show::after {
opacity: 1;
position: fixed;
visibility: visible;
z-index: 10;
}
}
}
Extension Configuration
{
"stylelint.snippet": [
"css",
"scss"
],
"stylelint.validate": [
"css",
"scss"
],
}
Actual Behaviour
Format Document not working
Expected Behaviour
Format Document should working
Logs
I am not sure when/where to use the NODE_ENV since I am using WLS2 on Windows?
Anyway, the current Stylelint OUTPUT is as follows:
/var/www/xxxx/xxxxxx/xxxxxx/assets/scss/style.scss: When linting something other than CSS, you should install an appropriate syntax, e.g. "postcss-scss", and use the "customSyntax" option
/var/www/xxxx/xxxxxx/xxxxxx/assets/scss/style.scss: When linting something other than CSS, you should install an appropriate syntax, e.g. "postcss-scss", and use the "customSyntax" option
/var/www/xxxx/xxxxxx/xxxxxx/assets/scss/style.scss: When linting something other than CSS, you should install an appropriate syntax, e.g. "postcss-scss", and use the "customSyntax" option
Stylelint Version
14.1.0
vscode-stylelint Version
1.2.0
Node.js Version
v16.13.0
Operating System
Ubuntu 20.04 focal on WSL2
Windows Subsystem for Linux
WSL2 on Win 10 , x64 10.0.19043
Code of Conduct
- I agree to follow vscode-stylelint’s Code of Conduct
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 9
- Comments: 21 (3 by maintainers)
I’m assuming since this issue hasn’t been closed that no fix has been released yet? I’m also experiencing the same exact problem.
My stylelint config is in
package.json. The only thing I’m doing is extending the SCSS standard like so:.vscode/settings.json:Package versions:
Symptoms: Running
stylelint --fixdirectly from the command line works fine. Also, opening an.scssfile in vscode and running the commandStylelint: Fix all auto-fixable Problemsworks fine. Syntax/rule errors also appear in.scssfiles in vscode.The only thing that doesn’t work is vscode’s
Format Documentcommand. Invoking via right-click or hotkeys (Ctrl+Shift+I for me) makes no difference. The following error always occurs:Installing
postcss-scssdirectly and adding it as acustomSyntaxmakes no difference.Same problem
Thank you @EvanShaw for your perfect description of the bug. 👍🏼 I’m having the exact same problem with the same configuration.
Blocked by https://github.com/stylelint/stylelint/issues/5723
Once implemented, we’ll make changes here to resolve the Stylelint config for a given file and then use it as a base for the formatting options provided by the client.
Same problem still. VSCode
Format Documentis not working when stylelint uses settings automaticaly from.stylelintrc.jsonin project root or whenconfigFileis used. To haveFormat Documentworking we must paste settings directly into VSCodesetting.json(user or workspace) viastylelint.config. So commiting.stylelintrc.jsonto repo to share with team is useless whenFormat Documentis not working 😦I have the same problem!
Able to replicate this. To format documents, we take the formatting options (e.g. indent size, tabs or spaces) from VS Code, convert them into their respective Stylelint rules (e.g. the
indentationrule), then give Stylelint this configuration to work with. However, it looks like Stylelint doesn’t merge these options with the configuration it finds. Instead, when it sees configuration options passed via the API, it stops looking for config files. So effectively, it tries to run without the syntax settings in your Stylelint config and throws the error you see in the log.I think that the best way to handle this is to have a way to tell Stylelint, “hey, these options are actually meant to override options you find, so keep looking for a config file.” Otherwise, we’d have to effectively duplicate the logic Stylelint already has for searching for, reading, and making sense of config files, which I don’t think would be the best way forward. I’ll raise an issue upstream to try and figure out what’s the best way to handle this issue and I’ll link it here.