RepoSense
RepoSense copied to clipboard
Use Husky pre-push hooks to run linters
There are often cases when we:
- Push our work to our remote repo
- Realise the CI checks failed due to a code style issue
- Resolve the style issues locally and push to the remote repo again
This process can be avoided if we automatically run the linters before git push
is executed.
We can use a git hook for this
@jylee-git @fzdy1914 what do you think about this suggestion?
Let's abandon this. I think that it is better if such errors appear on GitHub itself instead of locally as a Git hook, so that it is easier for senior developers to guide newcomers if necessary. In other cases, code style issues are minor and does not affect the review workflow.
Having this hook requires writing a custom script which adds additional maintenance burden.
Pretty sure that when code style issues are detected the CI tests would just fail, and senior developers usually do not look at PR with failed tests. I think a hook which checks for code style would be nice since if I forgot to run the linter before I push, I get reminded of my mistakes immediately instead of 5min later when the CI fails.
We don't use this technique in our other projects. Which means we can survive without it. But I don't mind giving it a try just to see how it goes. There might be some value if not a lot. Let's keep it, but with a low priority.
I think one possible reason why this issue is relevant is because of the different abstraction level for Run environmental checks
in integration.yml
compared to other linters:
https://github.com/reposense/RepoSense/blob/25f4ce29e45c0365c0627c835812fe5e29090eb0/.github/workflows/integration.yml#L155-L156
Most other linters are run in Gradle (lintFrontend
and checkstyleAll
), so developers are likely to forget about the existence of (and need to run) ./config/gh-actions/run-checks.sh
. If we make it a Gradle task (and mention it in the Developer Guide), developers are more likely to know about this particular check.