precommit those things

First, use the background

We have to add npm scripts in the lint command, but a lot of people forget when submitting the code or not used to perform a check, the result is leading to non-compliant code is uploaded to a remote code repository.

Second, the problem analysis
We can do pre-commit code that were `` mandatory testing, that is, once the code is detected before git commit, non-compliant code, not to commit.
Third, the solution

1, tool selection

2, comparative analysis

- husky (jquery and next.js in use) and pre-commit (antd in use), are git hook.
- husky is an added hook for git client tools, to prevent non-standard code commit, push, merge, it will be in the root directory of our project .git / hooks folder below to create a pre-commit, pre-push, etc. hooks, these hooks allow us to directly run the command we want to execute at some stage in package.json hook in the script.
- pre-commit to prevent non-standard code commit, but not so comprehensive husky, you may have to install the pre-push and other plug-in to prevent the corresponding git operations.

3. Conclusion

Use husky as git hook.

 

Guess you like

Origin www.cnblogs.com/camille666/p/precommit.html