g-plane / malva

Configurable, smart and fast CSS/SCSS/Sass/Less formatter, with dprint integration which behaves as dprint-plugin-css, dprint-plugin-scss, dprint-plugin-sass and dprint-plugin-less but all in one.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🌷 Malva

Malva is a configurable, smart and fast CSS/SCSS/Sass/Less formatter.

Why?

Configurable

Malva is configurable. It provides several configuration options so you can control the code style as you want.

Given the example below:

button.disabled, button:disabled {}

This selector is short enough to be put on single line, so Malva will put it on a single line by default, instead of forcing it to be splitted into multiple lines.

However, if you prefer putting into multiple lines, you can configure it.

Smart

Given the example below:

button.disabled/*please use pseudo class as possible*/,button:disabled {}

There're comments inside selector. Some formatters will fail to format it, but Malva will format as:

button.disabled /*please use pseudo class as possible*/, button:disabled {}

Try this on playground.

Also, thanks to the Raffia parser, Malva supports cutting edge CSS syntaxes like @container.

Support (indented) Sass

Malva supports indentation-based Sass, not just SCSS.

Quick Start

Try It Online

If you just want a quick try, you can try with the online playground.

dprint

We've provided dprint integration.

Run the command below to add plugin:

dprint config add g-plane/malva

After adding the dprint plugin, update your dprint.json and add configuration:

{
  // ...
  "plugins": [
    "https://plugins.dprint.dev/g-plane/malva-v0.1.4.wasm"
  ],
  "malva": {
    // Malva config comes here
  }
}

You can also read dprint CLI documentation for using dprint to format files.

Standalone CLI

Currently we don't provide standalone CLI. Leave a comment in Discussion and let us know if you need it.

Configuration

Please refer to Configuration.

FAQ

I don't like some of code styles. Can I propose to change it?

Malva is not opinionated and is configurable, and we accept different code styles then switch them with configuration. But before proposing a code style change, it's better to open a new issue or discussion.

My CSS code is in HTML/Vue/Svelte files. How can I format them?

If you're using dprint, you can use markup_fmt which provides a dprint plugin, then you can use these two plugins together.

Credit

Tests come from Prettier.

License

MIT License

Copyright (c) 2023-present Pig Fang

About

Configurable, smart and fast CSS/SCSS/Sass/Less formatter, with dprint integration which behaves as dprint-plugin-css, dprint-plugin-scss, dprint-plugin-sass and dprint-plugin-less but all in one.

License:MIT License


Languages

Language:Rust 100.0%