贡献指南¶
感谢您有兴趣为 linthis 做贡献!
开始之前¶
前提条件¶
- Rust 1.75+(稳定版)
- Cargo
克隆和构建¶
git clone https://github.com/zhlinh/linthis.git
cd linthis
cargo build
运行测试¶
cargo test
运行 Clippy¶
cargo clippy
开发流程¶
- Fork 仓库
- 创建功能分支:
git checkout -b feature/my-feature - 进行更改
- 运行测试:
cargo test - 运行 clippy:
cargo clippy - 提交更改:
git commit -m "feat: add my feature" - 推送到您的 fork:
git push origin feature/my-feature - 开启 Pull Request
代码风格¶
- 遵循 Rust 标准约定
- 使用
rustfmt进行格式化 - 使用
clippy进行代码检查 - 为新功能编写测试
- 为公共 API 编写文档
提交信息¶
我们遵循约定式提交:
feat:- 新功能fix:- Bug 修复docs:- 文档更改refactor:- 代码重构test:- 测试更改chore:- 构建/工具更改
示例:
feat(python): add support for mypy
fix(cli): handle empty file list correctly
docs: update installation instructions
添加语言支持¶
要添加对新语言的支持:
- 在
src/checkers/<language>.rs中创建检查器 - 在
src/formatters/<language>.rs中创建格式化器 - 在
src/lib.rs中为Language枚举添加语言变体 - 更新扩展名映射
- 添加安装提示
- 编写测试
- 在
docs/languages/<language>.md中创建文档
参考现有实现作为示例。
项目结构¶
src/
├── main.rs # CLI 入口点
├── lib.rs # 主库
├── checkers/ # 语言检查器
├── formatters/ # 语言格式化器
├── config/ # 配置处理
├── plugin/ # 插件系统
├── cli/ # CLI 命令
└── utils/ # 工具函数
测试¶
单元测试¶
cargo test
集成测试¶
cargo test --test integration
特定测试¶
cargo test test_name
文档¶
- 在
docs/目录更新文档 - 使用 MkDocs 进行本地预览:
mkdocs serve - 保持 README.md 与重大更改同步
有问题?¶
- 为 bug 或功能请求开启 issue
- 为问题发起讨论
- 创建新 issue 前检查现有 issue
许可证¶
通过贡献,您同意您的贡献将在 MIT 许可证下获得许可。