More consistent raws convention for trailing whitespace
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- typescript
- 領域
- tooling
研究方向
No files or tests are named. Start by tracing how Container.raws.after, AtRule.raws.between, and Declaration.raws.value.raw are populated and consumed, then compare the parser and serializer behavior for trailing whitespace with and without semicolons. Done means the proposed raws conventions are implemented consistently and covered by tests, including the lower-priority AtRule rename if accepted.
由索引模型根據 Issue 內容生成。
描述
This is a request to support https://github.com/sass/dart-sass/issues/88.
There are a few inconsistencies and difficulties in the way raws work with trailing whitespace. For my purposes the main issue here is that these make it hard to expand on the rules in a PostCSS-compatible Sass parser, but I imagine the inconsistencies also make it difficult to work with raws in general. In particular:
-
raws.betweenrepresents substantially different content for at-rules (where it represents the whitespace after the rule's params) and declarations (where it represents the whitespace and colon after the declaration's name). This makes it difficult to share formatting logic between at-rules and declarations. -
Declarations and at-rules use different raws conventions for the final node in a block when that node doesn't have a semicolon. In particular,
a {@foo }puts the two spaces inAtRule.raws.between, whilea {foo: bar }puts the two spaces inRule.raws.after. -
At-rules have an explicit representation of trailing whitespace that's distinct from the value of the rule in
AtRule.raws.between, but declarations do not. Instead, trailing whitespace in declarations is represented as trailing whitespace inDeclaration.raws.value.raw. This makes it difficult to change the declaration's value while preserving the whitespace.
The final bullet point is particularly problematic for any tool that tries to expose a parsed view of a declaration value in a way that matches the PostCSS API. This view has to be responsible for maintaining all the formatting intrinsic in Declaration.raws.value.raw, which means it must somehow track the trailing whitespace. However, this poses a serious issue: the PostCSS convention for raws in the common case of nodes immediately followed by semicolons or blocks is that a given node tracks the whitespace before it but not after it. If each expression node has to track whitespace after it, then that ends up working substantially differently than PostCSS.
I propose the following changes:
-
Make
Container.raws.afteralways contain the whitespace between}and the previous semicolon, block, or node, whichever is closer. This matches the current behavior of declarations, nested style rules, and at-rules with blocks or semicolons. It only changes the behavior of at-rules without semicolons. -
Add
Declaration.raws.afterValue, which holds any whitespace between the declaration value and the semicolon. If there is no semicolon, this is parsed as the empty string and the whitespace is inContainer.raws.afterinstead. -
(Lower priority) Rename
AtRule.raws.betweento.afterValueto make it fully analogous toDeclaration.raws.afterValue.
- 主要語言
- TypeScript
- 星號
- 29k
- 分支
- 1.8k
- 平均合併
- 18 小時 58 分鐘
- 30 天內合併 PR
- 9
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
postcss/postcss 的其他 Issue
-
Put opnly `major.minor` in `Processor.version`可能已有人在做 @MahinAnowar 於 144 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
Multiple BOM symbols inside generated css in v8.5.24可能已有人在做 @arronKler 於 104 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 50/100
postcss/postcss#2133 · 9 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
Remove colors lib可能已有人在做 @mrpmohiburrahman 於 100 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 55/100
維護者通常 1 天內回覆
-
Add a way to create plugins in TypeScript可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 4/5 3-5 天 新手友好度 45/100
postcss/postcss#2102 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 25/100
postcss/postcss#2053 · 1 則留言 ·
維護者通常 1 天內回覆
相似的 Issue
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難度 1/5 1 小時以內 新手友好度 82/100
lingdojo/kana-dojo#34714 · 1 則留言 · 5 個 reaction ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 70/100
-
needs-triage
難度 2/5 1-3 小時 新手友好度 72/100
manaflow-ai/cmux#59692 ·
維護者通常 1 天內回覆
-
Retire stale Python-parity labels in Rust ingress and auth tests可能已有人在做 @github-actions 今天認領。 未關閉factory factory:building factory:unowned ralph-status:in-progress via:opencode-free/hy4-flash-free
難度 2/5 1-3 小時 新手友好度 82/100
JoshCLWren/comic-pile#5874 · 2 則留言 ·
維護者通常 1 天內回覆
-
area: community lane: free-agent priority: P1 roadmap type: task
難度 2/5 1-3 小時 新手友好度 66/100
velella-sh/offing#1046 ·
維護者通常 1 天內回覆