Opinionated code formatter for TypeScript and JavaScript.
Read rules/mod.rs and tests/rules.rs for more information.
Go to the release page.
cargo install sane-fmt
npm i -g @sane-fmt/wasm32-wasi
The WASM package while work on all platform, it is slow to start. For better speed, install one of the following packages instead:
For Linux: * @sane-fmt/x8664-unknown-linux-gnu * @sane-fmt/x8664-unknown-linux-musl
For macOS: * @sane-fmt/x86_64-apple-darwin
For Windows: * @sane-fmt/x8664-pc-windows-gnu * @sane-fmt/x8664-pc-windows-msvc
yay -S sane-fmt
yay -S sane-fmt-bin
sh
sane-fmt --write
This command would reformat all TypeScript and JavaScript files.
sh
sane-fmt
This command would check all TypeScript and JavaScript files.
sh
sane-fmt --write foo.ts bar.js
This command would only reformat foo.ts
and bar.js
.
sh
sane-fmt --write src/
This command would reformat all TypeScript and JavaScript files within src/
directory.
sh
sane-fmt --help
sane-fmt
is an opinionated code formatter for TypeScript and JavaScript powered by dprint. You can think of it as a portable Dprint config file that is always up-to-date.
I want to apply a single, consistent formatting for all my codes regardless of environment without complex tooling.
I have considered using Prettier or Dprint, but that would mean having to set up Node.js even in non-Node.js environments. I also don't like copying my config files back-and-forth to update them.
On the other hand, setting up sane-fmt
is simple: just download the binary.
Customization is antithetical to the purpose of this project. Just fork this project if you want your own version of sane-fmt
, or just use Dprint if you want convenient customization.
I plan to divide this package into multiple reusable crates in the future, this would allow crate user to provide their own rules to create their own version of sane-fmt
. However, I will never make the rule configurable for the end-user.