Firstly, thank you for taking interest in advancing the Sway language formatter! This guide will walk you through installation and best practices for contributing to this project.
Pre-Installation: If you've previously installed
forc-fmt
viafuelup
, you will need to uninstall it in order to use the binary compiled from source.
# find fuelup `forc-fmt` binary
which forc-fmt
# output: `~/.fuelup/bin/forc-fmt`
#
# remove fuelup `forc-fmt` binary
rm ~/.fuelup/bin/forc-fmt
Note:
cargo
is a prerequisite to this build.
# 1. move to your preferred directory
# example: cd ~/Code/
#
# 2. clone the Sway repo
git clone https://github.com/FuelLabs/sway.git
#
# 3. build from manifest and move the compiled result to your `.cargo/bin` folder
cargo build --path ~/sway/forc-plugins/forc-fmt/Cargo.toml && mv ~/sway/target/debug/forc-fmt ~/.cargo/bin
Be sure to have forc
installed then move into a Sway project directory and execute the binary:
forc fmt
Issues:
- Please check existing issues before opening a new ticket.
- If a bug or feature you would like to see implemented isn't represented by an issue please use our issue template and submit all relevant details.
Note: please keep in mind, it is not the goal of
swayfmt
to be identically configurable torustfmt
and that some requested features may remain unimplemented until a consensus is reached on adding them
Pull Requests:
- Each issue should be linked to its corresponding pull request with either a closing or reference keyword.
- If not enough context is provided by an issue please request a more detailed explanation or look to
rustfmt
as a definitive reference. - When taking on a task leave a comment so that a member can assign you. This prevents multiple people from taking on the same work.
- If you are implementing a new feature, or fixing a bug please provide unit tests to show the effectiveness of the changes you've made and follow the formatting guidelines of the test cases currently available.
- Adjustments to formatted whitespace, or adding
char
s should always be behind aconst
if not provided by thesway_ast
. - Lastly, keep in mind that we aim to avoid unnecessary memory reallocations e.g.
String::new()
or.clone()
, destructive operations such as.pop()
, and prefer usingstd::fmt::Write
macros for appendingFormattedCode
.