-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Tin Chung <[email protected]>
- Loading branch information
1 parent
7c69607
commit 7eb9981
Showing
39 changed files
with
953 additions
and
854 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Git Hooks | ||
|
||
A pre-push hook which checks formatting of Rust files. Additional checks may be added in the future. | ||
|
||
# Prerequisites | ||
|
||
The following prerequisites are required: | ||
|
||
## Rust Nightly | ||
|
||
The nightly version of Rust provides additional formatting benefits over the stable version. | ||
|
||
```shell | ||
rustup toolchain install nightly --profile minimal --component rustfmt | ||
``` | ||
|
||
# Installation | ||
|
||
Use the following command in the root directory of the local repository to configure Git to use the hooks: | ||
|
||
```shell | ||
git config core.hooksPath .githooks | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
# Check Rust formatting | ||
if ! cargo +nightly fmt --all -- --check | ||
then | ||
echo "There are some code style issues." | ||
# shellcheck disable=SC2006 | ||
echo "Run 'cargo +nightly fmt --all' first." | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
# Basic | ||
# Non-default formatting configuration options: use with `cargo +nightly fmt --all` | ||
binop_separator = "Back" | ||
chain_width = 80 | ||
combine_control_expr = false | ||
comment_width = 100 | ||
condense_wildcard_suffixes = true | ||
edition = "2021" | ||
format_code_in_doc_comments = true | ||
format_strings = true | ||
group_imports = "StdExternalCrate" | ||
hard_tabs = true | ||
max_width = 100 | ||
use_small_heuristics = "Max" | ||
# Imports | ||
imports_granularity = "Crate" | ||
reorder_imports = true | ||
# Consistency | ||
newline_style = "Unix" | ||
# Misc | ||
chain_width = 80 | ||
spaces_around_ranges = false | ||
binop_separator = "Back" | ||
reorder_impl_items = false | ||
match_arm_leading_pipes = "Preserve" | ||
match_arm_blocks = false | ||
match_block_trailing_comma = true | ||
trailing_comma = "Vertical" | ||
newline_style = "Unix" | ||
normalize_comments = true | ||
reorder_impl_items = true | ||
trailing_semicolon = false | ||
unstable_features = true | ||
use_field_init_shorthand = true | ||
# Format comments | ||
comment_width = 100 | ||
# Uses max_width or its default value (100) if not specified. | ||
use_small_heuristics = "Max" | ||
use_try_shorthand = true | ||
wrap_comments = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# all options https://taplo.tamasfe.dev/configuration/formatter-options.html | ||
|
||
exclude = [ "networks/**", "target/**" ] | ||
|
||
# global rules | ||
[formatting] | ||
array_auto_collapse = false | ||
array_auto_expand = true | ||
compact_arrays = false # zepter compatibility | ||
indent_string = " " # tab | ||
inline_table_expand = false | ||
reorder_arrays = true | ||
reorder_keys = true | ||
|
||
[[rule]] | ||
include = [ "Cargo.toml" ] | ||
keys = [ "workspace.dependencies" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.