Add .editorconfig
and rustfmt.toml
for Consistent Code Formatting
#1508
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces two configuration files,
.editorconfig
andrustfmt.toml
, to enforce consistent code formatting across the project. These additions aim to standardize indentation, line endings, maximum line length, and other formatting rules for Rust and Python files, ensuring the codebase is uniform and easier to maintain.Key Changes
.editorconfig
:rustfmt.toml
:.editorconfig
ConfigurationThe
.editorconfig
file includes the following rules:Global Settings:
indent_style = space
: Use spaces for indentation.indent_size = 2
: Use 2 spaces per indentation level.insert_final_newline = true
: Ensure every file ends with a newline.end_of_line = lf
: Use Unix-style line endings.charset = utf-8
: Set UTF-8 as the default encoding.Python Settings:
max_line_length = 88
: Follows PEP 8 guidelines for Python files.Rust Settings:
max_line_length = 100
: Maximum line length for Rust files.rustfmt.toml
ConfigurationThe
rustfmt.toml
file includes the following rules:max_width = 100
: Maximum line width for Rust code.hard_tabs = false
: Use spaces, not tabs, for indentation.tab_spaces = 2
: Each tab equals 2 spaces.newline_style = "Unix"
: Unix-style line endings.Rationale
These configurations promote consistent code formatting, reducing inconsistencies across the codebase. By following these standards, the team can ensure that code reviews and merges proceed smoothly, minimizing formatting-related issues.
Instructions for Team Members
Editor Integration:
Ensure your IDE or code editor supports
.editorconfig
andrustfmt.toml
.Use
cargo fmt
:After merging this PR, run
cargo fmt
to apply the Rust-specific formatting rules.Automated Checks:
If using a continuous integration (CI) system, add a step to verify that Rust code is formatted with
cargo fmt -- --check
.