[Bug] stylelint customSyntax postcss-lit deletes custom variables
- Vorherrschende Sprache
- TypeScript
- Sterne
- 90
- Forks
- 9
- Ø Merge
- 1 T. 9 Min.
- Gemergte PRs (30 T.)
- 3
Beschreibung
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%;
}
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
The issue is in the custom syntax parser for postcss-lit, which processes CSS inside template literals. Look at the parsing logic in the source files (likely in src/ or lib/) to see how it handles line breaks and variable interpolation. The bug appears when a CSS selector with multiple interpolated variables is split across lines. Start by reproducing the described scenario with a test file, then trace through the parsing to see where the variable tokens are lost.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- devtools, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100