{"id":23551364,"url":"https://github.com/rockmagma02/rust-pre-commit-hooks","last_synced_at":"2025-05-15T15:12:23.162Z","repository":{"id":269592419,"uuid":"907855378","full_name":"rockmagma02/rust-pre-commit-hooks","owner":"rockmagma02","description":"A set of pre-commit hooks for Rust projects","archived":false,"fork":false,"pushed_at":"2024-12-24T17:13:10.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T15:12:22.622Z","etag":null,"topics":["clippy","developer-tools","pre-commit","pre-commit-hook","pre-commit-hooks","rust","rustfmt"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rockmagma02.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-24T15:01:50.000Z","updated_at":"2024-12-24T17:13:47.000Z","dependencies_parsed_at":"2024-12-24T17:38:35.886Z","dependency_job_id":null,"html_url":"https://github.com/rockmagma02/rust-pre-commit-hooks","commit_stats":null,"previous_names":["rockmagma02/rust-pre-commit-hooks"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockmagma02%2Frust-pre-commit-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockmagma02%2Frust-pre-commit-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockmagma02%2Frust-pre-commit-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockmagma02%2Frust-pre-commit-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rockmagma02","download_url":"https://codeload.github.com/rockmagma02/rust-pre-commit-hooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364271,"owners_count":22058879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clippy","developer-tools","pre-commit","pre-commit-hook","pre-commit-hooks","rust","rustfmt"],"created_at":"2024-12-26T10:19:22.423Z","updated_at":"2025-05-15T15:12:23.142Z","avatar_url":"https://github.com/rockmagma02.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable no-inline-html first-line-heading no-emphasis-as-heading ol-prefix --\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n# Rust Pre-Commit Hooks\n\n**A set of pre-commit hooks for Rust projects**\n\n[![GitHub License](https://img.shields.io/github/license/rockmagma02/rust-pre-commit-hooks)](https://github.com/rockmagma02/rust-pre-commit-hooks/blob/main/LICENSE)\n[![GitHub Release](https://img.shields.io/github/v/release/rockmagma02/rust-pre-commit-hooks)](https://github.com/rockmagma02/rust-pre-commit-hooks/releases)\n[![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/rockmagma02/rust-pre-commit-hooks)](https://github.com/rockmagma02/rust-pre-commit-hooks/issues)\n[![GitHub Issues or Pull Requests](https://img.shields.io/github/issues-pr/rockmagma02/rust-pre-commit-hooks)](https://github.com/rockmagma02/rust-pre-commit-hooks/pulls)\n[![Static Badge](https://img.shields.io/badge/pre--commit-hooks-blue)](https://pre-commit.com/)\n![GitHub Repo stars](https://img.shields.io/github/stars/rockmagma02/rust-pre-commit-hooks)\n\n\u003c/div\u003e\n\n## Table of Contents\n\n\u003c!-- markdownlint-disable ul-indent --\u003e\n\n- [Implementation](#implementation)\n- [Hooks](#hooks)\n    - [Code Formatting](#code-formatting)\n    - [Linting](#linting)\n    - [Example](#example)\n- [Known Issues](#known-issues)\n- [License](#license)\n\n\u003c!-- markdownlint-enable ul-indent --\u003e\n\n## Implementation\n\nThis project uses a `build.rs` script to automatically install and configure necessary Rust components (rustfmt and clippy) for all installed toolchains. The build script:\n\n1. Detects all installed Rust toolchains\n2. Installs `rustfmt` and `clippy` components for each toolchain\n3. Ensures rustup is properly initialized\n\nThis approach ensures that the pre-commit hooks will work correctly regardless of which Rust toolchain you're using.\n\n## Hooks\n\nThe following pre-commit hooks are available:\n\n### Code Formatting\n\n- **rustfmt**: Formats individual Rust files using `rustfmt`\n  - ID: `rustfmt`\n  - Runs on: `.rs` files\n\n- **rustfmt-check**: Checks if Rust files are properly formatted without modifying them\n  - ID: `rustfmt-check`\n  - Runs on: `.rs` files\n\n- **cargo-fmt**: Formats all bin and lib files in the current crate\n  - ID: `cargo-fmt`\n  - Runs on entire project\n\n- **cargo-fmt-check**: Checks formatting of all bin and lib files without modifying them\n  - ID: `cargo-fmt-check`\n  - Runs on entire project\n\n### Linting\n\n- **clippy**: Runs Clippy lints on all crates in the project\n  - ID: `clippy`\n  - Runs on entire project\n\n- **clippy-driver**: Runs Clippy lints on individual Rust files\n  - ID: `clippy-driver`\n  - Runs on: `.rs` files\n\n### Example\n\n```yaml\n# .pre-commit-config.yaml\n\n  - repo: https://github.com/rockmagma02/rust-pre-commit-hooks\n    rev: v0.1.0\n    hooks:\n      - id: rustfmt\n      - id: rustfmt-check\n      - id: cargo-fmt\n      - id: cargo-fmt-check\n      - id: clippy\n      - id: clippy-driver\n```\n\n## Known Issues\n\n1. When modifying (install new) Rust toolchains, you may need to reinstall the pre-commit hooks to ensure the components (rustfmt and clippy) are properly installed for the new toolchain.\n\n```bash\npre-commit uninstall\npre-commit clean\npre-commit install\n```\n\n2. the clippy-driver hook will compile all lib and bin files in the current crate. Will generate a set of binaries in the root of the project, which we strongly recommend not to use this hook.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/rockmagma02/rust-pre-commit-hooks/blob/main/LICENSE) file for details.\n\nThe MIT License is a permissive license that allows you to use, modify, and distribute this software for any purpose, provided that the license and copyright notice are included.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frockmagma02%2Frust-pre-commit-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frockmagma02%2Frust-pre-commit-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frockmagma02%2Frust-pre-commit-hooks/lists"}