# `IgniterCss.Codemods`
[🔗](https://github.com/ash-project/igniter_css/blob/v1.1.2/lib/igniter_css/codemods.ex#L5)

Igniter-facing wrappers: they take and return an `Igniter` struct, so callers
get Igniter's normal diff preview and confirmation flow for free.

Available only when `igniter` is a dependency. Without it, every function here
returns `{:error, :igniter_not_available}`; use `IgniterCss` directly instead.

## Comment ownership on delete

When a codemod removes a declaration or a rule, these comments go with it:

* a comment **trailing on the same line**;
* a comment on its **own line directly above**, with no blank line between.

These are kept:

* a comment separated from the target by a **blank line**;
* a comment that reads as a **section header** — one spanning several lines, or
  containing a rule of three or more repeated `= - * # ~ _` characters, e.g.
  `/* ===== Layout ===== */`;
* the comment the **file opens with** — it is the file's, and a rule inserted
  at the top lands right under it.

## Example

    def install(igniter, _opts) do
      igniter
      |> IgniterCss.Codemods.ensure_at_rule("assets/css/app.css", ~s|@plugin "daisyui";|)
      |> IgniterCss.Codemods.ensure_rule("assets/css/app.css", ".hide-scrollbar")
      |> IgniterCss.Codemods.set_declaration(
        "assets/css/app.css", ".hide-scrollbar", "scrollbar-width", "none"
      )
    end

Each step is idempotent, so re-running the installer produces no diff.

# `add_import`

See `IgniterCss.add_import/4`.

# `add_vendor_prefixes`

See `IgniterCss.add_vendor_prefixes/4`.

# `append_raw_to_rule`

See `IgniterCss.append_raw_to_rule/4`.

# `ensure_at_rule`

See `IgniterCss.ensure_at_rule/3`.

# `ensure_at_rule_block`

See `IgniterCss.ensure_at_rule_block/5`.

# `ensure_at_rule_declarations`

See `IgniterCss.ensure_at_rule_declarations/5`.

# `ensure_rule`

See `IgniterCss.ensure_rule/4`.

# `remove_at_rule`

See `IgniterCss.remove_at_rule/4`.

# `remove_at_rule_declarations`

See `IgniterCss.remove_at_rule_declarations/5`.

# `remove_declaration`

See `IgniterCss.remove_declaration/4`.

# `remove_import`

See `IgniterCss.remove_import/3`.

# `remove_rule`

See `IgniterCss.remove_rule/3`.

# `set_declaration`

See `IgniterCss.set_declaration/5`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
