43081j / 43081j/postcss-styled-components

Autofix generates invalid code with nested style blocks

未关闭
#9 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
12
派生
1
PR 合并指标
30 天内没有已合并 PR

描述

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;
}
`;
```

贡献指南

这个仓库没有索引到贡献指南

调研方向

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.

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
developer-experience, tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。