
Product
Socket for Asana Is Now Available
Create and manage Asana tasks directly from Socket alerts, with manual task creation, automated ticketing rules, and two-way sync.
@svjunic/css-cascade
Advanced tools
CSS diff tool that compares effective property values by applying cascade rules, not raw text
CSS の変更内容を構造レベルで比較するツールです。単純な文字列差分ではなく、同一セレクタ内で最終的に有効になるプロパティを算出したうえで新旧を比較します。
/css-cascade コマンドの概要・セットアップ・検証の観点単純な文字列差分ではなく、ブラウザと同じカスケードルールを適用した最終値で比較します。
.a { color: red; color: green; } は green だけを有効値として比較!important 優先 — !important の付与・削除も変更として検出.a, .b { } は .a と .b それぞれに展開して比較@media — メディアクエリごとに差分を分離して表示@font-face / @keyframes — フォントやアニメーションの差分にも対応CSS カスケードでは、同じ詳細度(specificity)を持つ複数のセレクタが同一エレメントにマッチするとき、出現順が後のルールが優先されます。DOM を使わずに、セレクタの相対的な出現順が変わったことを検知して警告します。
| パターン | 旧 CSS | 新 CSS | 警告 |
|---|---|---|---|
| 単純な並び替え | A→B→C→D | A→C→B→D | B と C の行に ⚠️ |
| 削除のみ(残りは順序維持) | A→B→C→D | A→C→D | B を削除行として表示(⚠️ なし) |
| 追加のみ(既存は順序維持) | A→B→C | A→X→B→C | X を追加行として表示(⚠️ なし) |
| 削除+並び替え | A→B→C→D | A→D→C | B 削除(⚠️ なし)+ C と D は ⚠️ |
⚠️ 行のうち、同一詳細度かつ競合プロパティ(同じプロパティを異なる値で定義)がある場合は、より強い警告を表示します。
calc(x * 2) と calc(x*2) のような書き方の違いを同一視(#FFF = #ffffff、先頭ゼロ省略、クォートの有無なども対象)[class*='list'] と [class*=list] を同一セレクタとして扱うcss-cascade/
├── data/
│ ├── old/module.css # 比較元(初期ロード用)
│ └── new/module.css # 比較先(初期ロード用)
├── src/
│ ├── core/
│ │ ├── parse.js # CSS → 中間モデル(PostCSS 使用)
│ │ ├── resolve.js # 後勝ちルール適用 → 最終プロパティ集合
│ │ ├── diff.js # 新旧の最終プロパティ集合を比較
│ │ ├── order-risk.js # セレクタ出現順の変更リスク検出
│ │ └── normalize.js # セレクタ・値の正規化ユーティリティ
│ ├── reporters/
│ │ └── html.js # HTML レポート生成(--format html)
│ └── ui/
│ ├── main.js # エントリーポイント・状態管理
│ ├── render.js # 差分結果の HTML 生成
│ ├── dropzone.js # ファイルドロップ UI
│ └── fuzzy.js # fzf によるファジー検索
├── tests/
│ ├── diff.test.js # diff ロジックのテスト
│ └── resolve.test.js # resolve ロジックのテスト
└── index.html
CSS テキスト
│
▼
parseCss() PostCSS でパースし、コンテキスト(base / @media 等)×
セレクタ×プロパティの宣言リストに変換
│
▼
resolve() 後勝ちルールと !important を適用し、
各セレクタの最終有効プロパティ集合を算出
│
▼
diff() 新旧の最終プロパティ集合をセレクタ・プロパティ単位で比較し、
added / removed / changed / unchanged のステータスを付与
| ライブラリ | 用途 |
|---|---|
| Vite | 開発サーバー・バンドル |
| PostCSS | CSS パース |
| fzf | ファジー検索 |
| Vitest | テスト |
FAQs
CSS diff tool that compares effective property values by applying cascade rules, not raw text
The npm package @svjunic/css-cascade receives a total of 8 weekly downloads. As such, @svjunic/css-cascade popularity was classified as not popular.
We found that @svjunic/css-cascade demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Product
Create and manage Asana tasks directly from Socket alerts, with manual task creation, automated ticketing rules, and two-way sync.

Security News
Open VSX has removed three extension IDs from its malicious-extension list as the legitimate publishers they impersonated move to claim the names for themselves.

Product
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.