vscode-stylelint: CSS properties in comments increase indefinitely.

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

I use VS Code’s stylelint plugin to automatically run fix when saving a file.

However, at this time, for some reason, the CSS property name being purchased within the comment is copied to the end of the comment. (There was no problem when I fixed it with the stylelint --fix command.

.test {
	color: red;
	background-color: #fff;

	// background-color: blue;
}

// .hoge{
//     color:yellow;
// }

https://github.com/stylelint/stylelint/assets/31400297/3ce325bf-b7a4-4fef-96da-58cfba620a8a

Also, this problem has been occurring since updating stylelint from v15 to v16.

What minimal configuration is needed to reproduce the bug?

.stylelintrc.cjs

module.exports = {
	extends: [
		'stylelint-config-recommended-scss',
	],
};

How did you run Stylelint?

This problem seems to occur when you use a VS Code extension to automatically format a file when saving it.

Which Stylelint-related dependencies are you using?

{
    "stylelint": "^16.2.0",
    "stylelint-config-recommended-scss": "^14.0.0",
}

What did you expect to happen?

I just want to save the file normally.

What actually happened?

CSS properties in comments increase indefinitely.

Do you have a proposal to fix the bug?

No response

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 5
  • Comments: 25 (11 by maintainers)

Most upvoted comments

Hey! Did anyone figure out a solution to this?

I tested the behavior a little, and here’s what I found out:

A ‘double slash comment’ seems to be parsed as part of the code, maybe by postcss-scss? So this: Image Will be converted to Image on save, and it just keeps adding the same string. To fix this, either adding a semicolon in the comment works Image Or changing the comment to a multi-line comment Image

Note that a) The semicolon must be the last character in the comment and b) multi-line comments will be included in the compiled css (at least when using the standard, unchanged dart-sass/sass-embedded compiler

FYI, I’ve just opened PR #492 to reduce confusion in README.

So I think VS Code plugin and stylelint v16 are incompatible.

It may be correct. The main branch hasn’t tested v16 yet:

https://github.com/stylelint/vscode-stylelint/blob/39e7c76070bb5cfe678ace65de3a30d69e092196/package.json#L249

@ddryo Thanks for the minimum reproduction. This problem seems specific to the VSCode extension, so I’ll transfer this issue to https://github.com/stylelint/vscode-stylelint.

This problem occurred when tested in an environment with only the following two files

pckage.json

{
	"name": "stylelint-test",
	"version": "1.0",
	"description": "",
	"main": "dist/index.js",
	"module": "dist/index.js",
	"scripts": {},
	"private": true,
	"license": "MIT",
	"devDependencies": {
		"stylelint": "^16.2.0"
	}
}

test.scss

.test {
	color: red;
	background-color: #fff;

	// background-color: blue;
	
}

// .hoge{
//     color:yellow;
// }

Yes, here is the setting data.

{
	"html.format.enable": false,
	"javascript.format.enable": false,
	"css.format.enable": false,
	"eslint.format.enable": false,
}

@ddryo Thanks for the report with a real reproduction video. Probably, this is the same problem as stylelint/vscode-stylelint#490.