Thanks for considering a contribution. This document spells out the conventions used when working on the project.
- Development Setup
- Coding Standards
- Git Workflow
- Commit Convention
- Pull Request Guidelines
- Testing Requirements
- Documentation Updates
- Rust 1.75.0+
- cargo
- Git
git clone https://github.com/Hiro-Chiba/fileview.git
cd fileview
cargo build
cargo test| Item | Convention | Example |
|---|---|---|
| Variables | snake_case | file_path, tree_state |
| Functions | snake_case | get_entries(), render_tree() |
| Types/Structs | PascalCase | AppState, FileEntry |
| Enums | PascalCase | OperationMode |
| Enum Variants | PascalCase | OperationMode::Normal |
| Constants | SCREAMING_SNAKE_CASE | MAX_PREVIEW_LINES |
| Modules | snake_case | file_system, event_handler |
| Traits | PascalCase | Renderable, FileOperation |
- Indentation: 4 spaces
- Line length: 100 characters max (80 preferred for documentation)
- Import order:
- Standard library (
std::) - External crates
- Internal modules (
crate::,super::)
- Standard library (
// Good
use std::path::PathBuf;
use ratatui::Frame;
use tokio::sync::mpsc;
use crate::app::AppState;
use crate::event::Event;- Public APIs (
pub) must carry doc comments (///). - Complex logic gets inline comments (
//). - TODO comments follow the form
// TODO(username): description.
- Avoid
unwrap()/expect()outside tests. - Define errors with
thiserrorand returnResult<T, E>. - Reserve
panic!for unrecoverable invariants.
main
│
└── feature/xxx # new features
└── fix/xxx # bug fixes
└── refactor/xxx # refactoring
└── docs/xxx # documentation updates
└── test/xxx # added or updated tests
<type>/<short-description>
Examples:
feature/add-preview-panel
fix/tree-scroll-overflow
refactor/event-handler
docs/update-readme
Follows Conventional Commits.
<type>(<scope>): <subject>
<body>
<footer>
| Type | Description |
|---|---|
feat |
new feature |
fix |
bug fix |
docs |
documentation only |
style |
formatting / whitespace, no logic change |
refactor |
code change that is neither a fix nor a feature |
perf |
performance improvement |
test |
added or fixed tests |
chore |
build process or tooling change |
Name the module the change targets, e.g. ui, event, fs, config, app.
- Imperative mood ("Add", "Fix", "Update").
- Start with a capital letter.
- No trailing period.
- 50 characters or fewer.
# Good
feat(ui): Add syntax highlighting to preview panel
fix(fs): Handle symlink loop detection
refactor(event): Extract key binding logic to separate module
docs: Update installation instructions
chore: Bump ratatui to 0.26
# Bad
added new feature # not imperative, no type
feat: Fixed bug # type contradicts subject
FEAT(UI): ADD FEATURE. # shouting, trailing periodFor breaking changes, add ! and include a BREAKING CHANGE: footer:
feat(config)!: Change configuration file format
BREAKING CHANGE: Configuration file format changed from JSON to TOML.
Migrate existing config.json to config.toml.
-
Confirm tests pass
cargo test cargo clippy -- -D warnings cargo fmt --check -
Clean up commits — group changes into meaningful commits, squash any WIP commits.
-
Rebase onto the latest main
git fetch origin git rebase origin/main
Same format as commit messages:
feat(ui): Add file preview panel
## Summary
1-3 lines describing what changed.
## Changes
- change 1
- change 2
- change 3
## Test Plan
- [ ] test item 1
- [ ] test item 2
## Screenshots (if applicable)
Attach screenshots for UI changes.
## Related Issues
Closes #123- All CI checks pass.
- At least one review approval.
- No merge conflicts.
- Squash merge into
main.
- Squash and merge: collapse multiple commits into one on merge.
- The merge commit message defaults to the PR title.
Run all of the following before opening a PR. CI re-checks them too.
# tests
cargo test
# lint (warnings are treated as errors)
cargo clippy -- -D warnings
# formatting
cargo fmt --checkRules when adding or changing features:
-
Document only implemented features. Skip anything that is not in the current code. Avoid grand framing ("VSCode-style", etc.) in favour of plain, accurate language.
-
When keybindings change:
- Update the keybinding tables in
README.mdanddocs/KEYBINDINGS.md. - Update
print_help()insrc/main.rs. - Update the help text in
src/handler/action.rs.
- Update the keybinding tables in
Open an issue if anything is unclear.