43081j / 43081j/postcss-styled-components

Some errors not reported

オープン
#2 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
12
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi @43081j 👋 First of all, thanks for all of your hard work on this and also `postcss-js-core`, so amazing!

It appears that some Stylelint errors are not reported with `customSyntax: 'postcss-styled-components'` along with setting some standard rules using `extends: ['stylelint-config-recommended']` (eg. such as [`property-no-unknown`](https://github.com/stylelint/stylelint-config-recommended/blob/7aba0e798636fe3a5218951ed1095a8f96744a44/index.js#L36)):

```js
import styled, { css } from 'styled-components';

const Div = styled.div`
/* ✅ declaration-block-no-duplicate-properties reported */
color: red;
color: red;
/* ❌ property-no-unknown not reported */
booooorder: 1px solid red;
`;

const divStyles = css`
/* ❌ declaration-block-no-duplicate-properties not reported */
color: red;
color: red;
/* ❌ property-no-unknown not reported */
booooorder: 1px solid red;
`;
```

It seems like the `css` tagged template literals are possibly not checked at all? 🤔

This is also similarly broken when using Emotion:

```js
import { css } from '@emotion/react';
import styled from '@emotion/styled';

const Div = styled.div`
/* ✅ declaration-block-no-duplicate-properties reported */
color: red;
color: red;
/* ❌ property-no-unknown not reported */
booooorder: 1px solid red;
`;

const divStyles = css`
/* ❌ declaration-block-no-duplicate-properties not reported */
color: red;
color: red;
/* ❌ property-no-unknown not reported */
booooorder: 1px solid red;
`;
```

I've created an interactive demo of this on Replit.

To use it, change to the Shell tab on the right and run `npm install` and then `npm run lint`.

Demo (Replit): https://replit.com/@karlhorky/customSyntax-postcss-styled-components#styled-components.js

Screenshot 2022-12-30 at 23 17 36

---

Note that this does not use the nesting or other features of Sass (eg. to test out #1) because I haven't been able to get `customSyntax: "postcss-styled-components/scss"` working yet, as I mentioned here:

- https://github.com/43081j/postcss-styled-components/pull/1#issuecomment-1368102189

I will open new issues about any problems with these features once I can get the other entrypoints working.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

The issue shows that `css` tagged template literals are not being linted. Start by examining the parser in the source code to see how it processes different template literal tags. Run the provided Replit demo to reproduce the bug. Look for tests related to styled-components and emotion to understand the expected behavior. The fix likely involves updating the parser to recognize and process the `css` tag.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
testing-qa, tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
65/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。