[Bug] stylelint customSyntax postcss-lit deletes custom variables
- Lingua principale
- TypeScript
- Stelle
- 90
- Fork
- 9
- Merge medio
- 1g 9m
- PR unite (30g)
- 3
Descrizione
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%;
}
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- devtools, tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100