Contributing
Thank you for your interest in contributing to FSH Lint!
Ways to Contribute
Section titled “Ways to Contribute”- Report bugs
- Suggest features
- Improve documentation
- Write code
- Create custom rules
- Help others in discussions
Getting Started
Section titled “Getting Started”Prerequisites
Section titled “Prerequisites”- Rust 1.80 or later
- Git
- Familiarity with FSH (FHIR Shorthand)
Development Setup
Section titled “Development Setup”- Fork the repository:
gh repo fork octofhir/fsh-lint-rs
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/fsh-lint-rs.gitcd fsh-lint-rs
- Build the project:
cargo build --workspace
- Run tests:
cargo test --workspace
Development Workflow
Section titled “Development Workflow”1. Create a Branch
Section titled “1. Create a Branch”git checkout -b feature/my-feature# orgit checkout -b fix/issue-123
2. Make Changes
Section titled “2. Make Changes”Follow the project structure:
crates/fsh-lint-core
- Core linting enginecrates/fsh-lint-rules
- Rule engine and built-in rulescrates/fsh-lint-cli
- Command-line interfacecrates/fsh-lint-devtools
- Developer tools
3. Write Tests
Section titled “3. Write Tests”Add tests for new functionality:
#[cfg(test)]mod tests { use super::*;
#[test] fn test_my_feature() { // Test implementation }}
4. Run Tests
Section titled “4. Run Tests”# Run all testscargo test --workspace
# Run specific testcargo test --package fsh-lint-core --test my_test
# With outputcargo test -- --nocapture
5. Format Code
Section titled “5. Format Code”cargo fmt --allcargo clippy --all-targets --all-features
6. Commit Changes
Section titled “6. Commit Changes”Follow conventional commits:
git add .git commit -m "feat: add new rule for profile validation"git commit -m "fix: correct cardinality checking logic"git commit -m "docs: update installation guide"
Commit types:
feat
: New featurefix
: Bug fixdocs
: Documentationtest
: Testsrefactor
: Code refactoringperf
: Performance improvementchore
: Maintenance
7. Push and Create PR
Section titled “7. Push and Create PR”git push origin feature/my-feature
Then create a pull request on GitHub.
Code Guidelines
Section titled “Code Guidelines”Rust Style
Section titled “Rust Style”Follow Rust API Guidelines:
- Use descriptive names
- Prefer iterators over loops
- Use
Result
for error handling - Document public APIs
- Write integration tests
Documentation
Section titled “Documentation”- Add doc comments to public APIs
- Include examples in doc comments
- Update user documentation
- Add changelog entries
Testing
Section titled “Testing”- Write unit tests for new code
- Add integration tests for features
- Include golden file tests for parser
- Test error cases
Adding a New Rule
Section titled “Adding a New Rule”- Create rule file in
crates/fsh-lint-rules/src/builtin/
:
use fsh_lint_core::{LintContext, Diagnostic, Severity};use crate::Rule;
pub struct MyRule;
impl Rule for MyRule { fn name(&self) -> &str { "category/my-rule" }
fn category(&self) -> RuleCategory { RuleCategory::Style }
fn severity(&self) -> Severity { Severity::Warning }
fn lint(&self, context: &mut LintContext) { // Implementation }}
-
Register in
crates/fsh-lint-rules/src/lib.rs
-
Add tests in
crates/fsh-lint-rules/tests/
-
Add documentation in
docs/
Review Process
Section titled “Review Process”- Automated checks run (tests, clippy, fmt)
- Maintainer reviews code
- Address feedback
- Approval and merge
Community
Section titled “Community”- GitHub Discussions: Ask questions
- GitHub Issues: Report bugs
- Pull Requests: Contribute code
License
Section titled “License”By contributing, you agree your code will be licensed under MIT or Apache-2.0.
Questions?
Section titled “Questions?”Open a discussion on GitHub or reach out to maintainers.