-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding formatting spec #8
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sure. Let's wait until FuelLabs/sway#265 is merged to see if @sezna has any feedback on the defaults.
Anything outstanding or can this be merged @emilyaherbert? |
The Sway repository is the only one that's adopted this formatting configuration (which could possibly be a chicken-and-egg problem) in this time. I would move to close this rather than require all other repos to adopt a new formatter configuration. |
cc @emilyaherbert to decide |
Er, is this right? It looks like the Rust SDK has the same file https://github.com/FuelLabs/fuels-rs/blob/7fb18dfeeb12519fc7e6bd87e8da003d2e8dc9ee/rustfmt.toml I'm open to closing this RFC (let's ignore the fact that it's been open since September haha 😅), aside from the fact that standardized formatting reduces noise and merge conflicts. As the number of outside contributors grows this will be more important, so if it needs to happen, it should be sooner rather than later IMO. |
reorder_imports = true | ||
reorder_modules = true | ||
tab_spaces = 4 | ||
use_field_init_shorthand = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a handy feature that helps prevent clippy warnings when enabled
use_field_init_shorthand = false | |
use_field_init_shorthand = true |
tab_spaces = 4 | ||
use_field_init_shorthand = false | ||
use_small_heuristics = "Default" | ||
use_try_shorthand = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one also makes sense to enable, no reason to keep the try!
macro around
use_try_shorthand = false | |
use_try_shorthand = true |
remove_nested_parens = true | ||
reorder_imports = true | ||
reorder_modules = true | ||
tab_spaces = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This auto formats imports into a nice format for diffing (requires nightly fmt though):
tab_spaces = 4 | |
imports_layout = "Vertical" | |
imports_granularity = "Crate" | |
tab_spaces = 4 |
use foo::{
a,
b
}
cc @xgreenx might have some extra suggestions :) |
to be documented in a `rustfmt.toml` file in the top level of each project. | ||
See below for an example of the default values for the file. | ||
|
||
```toml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another nice one for organizing imports is group_imports
```toml | |
```toml | |
group_imports = "StdExternalCrate" |
This PR adds a spec that details formatting requirements.