-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Background
The current project lacks automated validation before code commits, which may lead to the following issues:
-
Committing non-compliant code (e.g., syntax errors, messy formatting);
-
Inconsistent commit messages, which is not conducive to subsequent maintenance and version tracking;
-
Inefficiency in team collaboration due to the need for manual reminders of specifications.
Solution
Introduce the husky library and configure core Git hooks:
-
pre-commit: Trigger ESLint/Prettier checks to ensure code format and syntax compliance; -
commit-msg: Validate the format of commit messages (e.g., following Conventional Commits).
Advantages
-
Lightweight: husky is small in size (core dependency is only a few KB) with no additional performance burden;
-
Low intrusion: Only acts on Git hooks without modifying the core logic of the project;
-
Easy to maintain: Configuration files can be committed to the repository, and team members can take effect automatically after pulling the code.
Additional Notes
-
I have confirmed that there are no conflicts with the project's existing dependencies (current project dependencies: XX/None);
-
I can submit a PR to complete the configuration, ensuring the code complies with the project's existing specifications;
-
Please let me know if there are any other requirements (e.g., adding/removing hooks).