-
-
Notifications
You must be signed in to change notification settings - Fork 83
Description
🚀 Feature Request: init command with optional --lang and --framework parameters
Summary
It is requested that the prek initialization command (init) be extended to accept optional --lang (language) and --framework parameters. This would allow the tool to automatically scaffold a more relevant and production-ready initial configuration file (.pre-commit-config.yaml) based on the project's primary technology stack.
Motivation
Many languages and frameworks have popular, community-standard custom linters, formatters, and code quality tools (e.g., black for Python, eslint for JavaScript/React, go fmt for Go).
Currently, setting up a new project requires the user to manually:
- Identify the recommended quality tools for their stack.
- Look up the corresponding
pre-commithook repository URLs, revisions, and arguments. - Manually edit the
.pre-commit-config.yamlfile.
Implementing the --lang/--framework parameters would drastically simplify onboarding, encourage the adoption of best practices, and reduce boilerplate, allowing developers to set up a comprehensive quality gate with a single command.
Proposed Command Examples
# Initialize with standard Python hooks (e.g., black, flake8/ruff, isort)
pre-commit init --lang=python
# Initialize with JavaScript hooks, including React-specific linters (e.g., eslint + react-hooks plugin)
pre-commit init --lang=javascript --framework=react
# Initialize for a simple Go project (e.g., go fmt, go vet)
pre-commit init --lang go
# rust with bevy game engine (cargo fmt, clippy, bevy cli)
pre-commit init --lang=rust --framework=bevy
This will be of course a very OPINIONATED choice, but we can iterate on it over time ;-)