Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autofix duplicated properties within comments #7429

Closed
Zotova2008 opened this issue Dec 28, 2023 · 12 comments
Closed

Fix autofix duplicated properties within comments #7429

Zotova2008 opened this issue Dec 28, 2023 · 12 comments
Labels
status: needs clarification triage needs clarification from author

Comments

@Zotova2008
Copy link

Zotova2008 commented Dec 28, 2023

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

Scss. Основной форматировщик выбран Stylelint.
В настройках прописаны свойства.
Включение и отключение стандартного валидатора не влияет на ситуацию

(Scss. The main formatter selected is Stylelint.
The properties are specified in the settings.
Enabling and disabling the standard validator does not affect the situation)

"stylelint.enable": true,
"stylelint.validate": [
	"css",
	"less",
	"postcss",
	"scss",
	"sass"
],

при сохранении Stylelint начинает дублировать закомментированные свойства, при чем сколько раз сохранишь, столько же и добавит

(when saving, Stylelint begins to duplicate the commented out properties, and no matter how many times you save, the same number will be added)

1
2

What minimal configuration is needed to reproduce the bug?

{
"[scss]": {
	"editor.defaultFormatter": "stylelint.vscode-stylelint"
},
"stylelint.enable": true,
"stylelint.validate": [
	"css",
	"less",
	"postcss",
	"scss",
	"sass"
],
}

How did you run Stylelint?

VS Code плагин Stylelint

(VS Code plugin Stylelint)

Which Stylelint-related dependencies are you using?

{
"stylelint": "16.1.0",
"stylelint-config-htmlacademy": "^4.0.1",
}

What did you expect to happen?

Ожидалось, что при сохранении файл отформатируется без дублирования свойств

(It was expected that when saving the file would be formatted without duplicating properties)

What actually happened?

Дублируются закомментрированные свойства

(Commented out properties are duplicated)

Do you have a proposal to fix the bug?

Как исправить не знаю

(I don’t know how to fix it)

@jeddy3 jeddy3 changed the title Дублирование свойств при сохранении файла Fix autofix duplicated properties within comments Dec 29, 2023
@jeddy3 jeddy3 added the status: needs reproducible example triage needs reproducible demo or repo label Dec 29, 2023
@jeddy3
Copy link
Member

jeddy3 commented Dec 29, 2023

@Zotova2008 Thanks for the report and for using the template. I've added a translation to your issue.

Please create a minimum reproducible example so that we can best help you.

Firstly, can you confirm this is an issue using the Stylelint CLI?

If it is, then can you identify which part of the stylelint-config-htmlacademy config is triggering the problem as it uses the :

  • postcss-less custom syntax
  • postcss-scss custom syntax
  • stylistic custom rules plugin pack

I suggest starting with just the built-in rules, if that fixes the issue, then add on the plugin pack, and then custom syntaxes until you can narrow down the cause. The issue may be triggered by combining a rule with one of the custom syntaxes.

We'll only be able to fix the issue here if it's with Stylelint or one of the built-in rules.

@Zotova2008
Copy link
Author

Zotova2008 commented Jan 2, 2024

@jeddy3 Благодарю за перевод.

Stylelint настроен на автоматическое форматирование при сохранении файлов.
Форматировщик по умолчанию - Stylelint

Убрала плагин с конфигурацией,
1
2
проблема повторилась и теперь двоятся свойства и при форматировании stylelint и при встроенном в vscode форматировании.

Когда вернула обратно файл конфигурации,

"extends": [
  "stylelint-config-htmlacademy"
],

проблема осталась только при форматировщике по умолчанию - Stylelint

@r2musings
Copy link

This happens for us as well. Will try to get together a small sample that reproduces outside of our larger codebase.

image

@jeddy3
Copy link
Member

jeddy3 commented Jan 2, 2024

Will try to get together a small sample that reproduces outside of our larger codebase

Thank you. That'll help a lot.

@r2musings
Copy link

r2musings commented Jan 2, 2024

Check readme for repro. Basically, it happens when using "--fix".

https://github.com/r2musings/stylelint-comment-bug

@jeddy3
Copy link
Member

jeddy3 commented Jan 2, 2024

@r2musings Thank you. I was able to reproduce a minimal demo using your repo.

A comment with a colon triggers it. However, this only occurs for the default syntax and not for for postcss-less custom one.

In your repo, the Stylelint config is set up for vanilla CSS. Can you configure it for Less to see it that helps, please:

{ "extends": ["stylelint-config-standard-less"] }

@r2musings and @Zotova2008 If able, can you also share your complete Stylelint configuration files, please?

@jeddy3 jeddy3 added status: needs clarification triage needs clarification from author and removed status: needs reproducible example triage needs reproducible demo or repo labels Jan 2, 2024
@r2musings
Copy link

@jeddy3 That did fix it! Thanks for looking at my demo and providing that solution. I appreciate it!

@Zotova2008
Copy link
Author

{
  "extends": [
    "stylelint-config-htmlacademy"
  ],
  "overrides": [
    {
      "files": [
        "*.scss",
        "**/*.scss"
      ],
      "customSyntax": "postcss-scss"
    }
  ],
  "rules": {},
  "ignoreFiles": [
    "vendor/**/*.*"
  ]
}

@jeddy3
Copy link
Member

jeddy3 commented Jan 3, 2024

@Zotova2008 Thank you. The config looks okay.

Can you produce the problem using the CLI?

npx stylelint "reboots.scss" --fix

@Zotova2008
Copy link
Author

@Zotova2008Спасибо. Конфигурация выглядит нормально.

Можете ли вы создать проблему с помощью CLI?

npx stylelint "reboots.scss" --fix

нет, баг не воспроизводится, свойства не дублируются

@jeddy3
Copy link
Member

jeddy3 commented Jan 7, 2024

@Zotova2008 Thank you for confirming. It's either a bug with the VSCode extension or your local configuration.

Check that you haven't got a stylelint.config: {} in your VSCode configuration file as that would override the stylelint-config-htmlacademy config where the custom syntax is set.

I'll close the issue here as it's unlikely to be an issue with the stylelint package because the CLI works.

@jeddy3 jeddy3 closed this as completed Jan 7, 2024
@Zotova2008
Copy link
Author

Такой stylelint.config: {} настройки в vs code нет.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs clarification triage needs clarification from author
Development

No branches or pull requests

3 participants