[Bug] stylelint customSyntax postcss-lit deletes custom variables
- Lenguaje dominante
- TypeScript
- Estrellas
- 90
- Forks
- 9
- Merge medio
- 1 d 9 min
- PR fusionados (30 d)
- 3
Descripción
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%;
}
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
El problema está en el parser de sintaxis personalizado de postcss-lit, que procesa CSS dentro de template literals. Revisa la lógica de parsing en los archivos fuente (probablemente en src/ o lib/) para ver cómo maneja los saltos de línea y la interpolación de variables. El error aparece cuando un selector CSS con múltiples variables interpoladas se divide en varias líneas. Empieza reproduciendo el escenario descrito con un archivo de prueba, luego rastrea el parsing para ver dónde se pierden los tokens de variables.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Área
- devtools, tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100