43081j / 43081j/postcss-styled-components

Autofix generates invalid code with nested style blocks

Abierto
#9 4 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
12
Forks
1
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Test case 1:

```tsx
const Div = styled.div`
${css`
color: blue;
`}
`;
```

This code yields the error `Skipping template… as it included either invalid syntax or complex expressions the plugin could not interpret`, as described at #7.

Test case 2:

```tsx
const Div = styled.div`
${css`
color: blue;
`}

div {
position: absolute;
}
`;
```

This yields the error `Unexpected unknown type selector "POSTCSS_styled-components_0" (selector-type-no-unknown)` on the `${}` line. But what's really strange is what happens if you run stylelint with `--fix`. The output is this invalid code:

```tsx
const Div = styled.div`
${css`
color: blue;
`}

div {
position: absolute;
}
color: blue;
`}

div {
position: absolute;
}
`;
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Look at the parser in src/syntax.js and the transformer in src/transformer.js. The bug occurs when nested template literals with css blocks are processed. Start by reproducing the error with the given test cases, then trace how the plugin handles interpolation and nested style blocks. Check the output after autofix to see where duplication happens.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
developer-experience, tooling
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.