[Feature Request] API for reverting or resetting a node
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- typescript
調査の方向性
Start by reviewing the existing node.clone() and replaceWith() behavior described in the issue, including parent pointers, raws information, and other internal state. Compare the snapshot/revert, safe-cloning, and transactional alternatives, then establish the intended API and safety guarantees; the work is done when one approach is agreed and covered by tests.
索引モデルが issue の本文から書いたものです。
説明
As developers of tools built on PostCSS (like Stylelint), we often need to perform complex transformations on the AST. A key challenge arises in "generating fixes" scenarios where multiple independent rules might attempt to modify the same node.
Currently, to prevent conflicting writes, we generate only a single fix even if more than one rule targets the same node. This is suboptimal because many of these fixes might not actually conflict. A more powerful approach would be to "try" a fix, analyze its result, and then potentially "undo" or "revert" it if they overlap. (See https://github.com/stylelint/stylelint/issues/8639#issuecomment-3006023674)
A potential solution could be the addition of an API in PostCSS for reverting a node to a previous state. This could take several forms, some ideas include:
Snapshot/Revert mechanism: An explicit API to save and restore a node's state.
const snapshot = node.saveState();
// ... perform transformations on 'node' ...
// If we decide the transformation was incorrect:
node.revertTo(snapshot);
Safe cloning for reversal: One idea, discussed in the context of a Stylelint issue, is to clone a node before mutation and replace the mutated node with the clone to achieve a rollback.
const nodeClone = node.clone();
// ... perform transformations on 'node' ...
// To revert:
node.replaceWith(nodeClone);
However, it's currently unclear if this is a guaranteed "no-op" that is free of side effects (e.g., incorrect handling of parent pointers, raws information, or other internal state). Formalizing this pattern and ensuring its safety would be a viable solution.
A Transactional API: A higher-level API that handles the state management automatically (Like CSTTransformer in Python's LibCST).
const transaction = postcss.transaction(node);
if (isConflict) {
transaction.rollback();
} else {
transaction.commit(); // (or this is the default)
}
- 主要言語
- TypeScript
- スター
- 29k
- フォーク
- 1.8k
- 平均マージ
- 18時間 58分
- マージ済み PR(30日)
- 9
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 件 ·
メンテナーはふだん 1 日以内に返信
-
Remove colors lib対応中かも @mrpmohiburrahman が 100 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
Add a way to create plugins in TypeScript再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
postcss/postcss#2102 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
postcss/postcss#2047 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
postcss/postcss の issue をすべて見る
似ている issue
-
bug zoo
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
software-mansion/runntime#151 ·
メンテナーはふだん 4 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
sidebandstudio/clawtrate#728 ·
メンテナーはふだん 1 日以内に返信
-
enhancement github_actions help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tranquilo-art/tranquilo-app#254 ·
メンテナーはふだん 1 日以内に返信
-
docs good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
DojoCodingLabs/hermit#73 ·
メンテナーはふだん 1 日以内に返信
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Tfoucher5/fuzzy-toolkit#44 ·
メンテナーはふだん 1 日以内に返信