postcss-lit icon indicating copy to clipboard operation
postcss-lit copied to clipboard

[Bug] stylelint customSyntax postcss-lit deletes custom variables

Open danchitiga opened this issue 1 year ago • 2 comments

First of all big thanks for fixing the main issue with variables inside string literals in css files for lit components.

The bug happens when you are using both a linter (to cut long lines of css into multiple lines) and stylelint with customSyntax postcss-lit in the following scenario:

let's assume we have the following css (single line css selector): .long-class-name-container.${veryLongVariableNameAddedHere} .small-image-container span ${anotherVeryLongVariableNameAddedHere} img { width: 100%; height: 100%; }

This will get parsed after linting into: .long-class-name-container.${veryLongVariableNameAddedHere} .small-image-container span ${anotherVeryLongVariableNameAddedHere} img { width: 100%; height: 100%; }

And after stylelint into: .general-takeover-container./* missing variable veryLongVariableNameAddedHere here*/ .small-image-container span /* missing variable anotherVeryLongVariableNameAddedHere here*/ img { width: 100%; height: 100%; }

This is not happening when for example we have only one ${variable} at the end with "{" and gets parsed on the last line like: .long-class-name-container .small-image-container span ${anotherVeryLongVariableNameAddedHere} {

into .long-class-name-container .small-image-container span ${anotherVeryLongVariableNameAddedHere} { width: 100%; height: 100%; }

danchitiga avatar Dec 12 '22 16:12 danchitiga

do you happen to know which stylelint rule does that for you?

we do have some stylelint tests already so i can probably reproduce it fairly easily once i know which rule you're using inside stylelint.

43081j avatar Dec 12 '22 22:12 43081j

I think it is the following rule from prettier (https://prettier.io/docs/en/options.html), "printWidth": 120.

danchitiga avatar Dec 13 '22 09:12 danchitiga