web
web copied to clipboard
Husky pre post commit hooks
Links
- Issue: https://github.com/UPchieve/web/issues/338
Description
- Scripts are added to
pre-commitandpost-commithooks to ensure that automatic changes made by the linter are staged for the commit. - A stash is used to ensure that unstaged changes are kept in the working tree, and only staged files are linted before they are committed.
- It's possible someone could stage some changes, run
git commitmeaning to commit the originally staged changes, then make further changes while the linter is still running. If the commit fails, then this setup will overwrite the original changes with the new changes. We should address this edge case at some point, but for now most people will probably not want to bring back lint errors that have been auto fixed.
Developer self-review checklist
- [x] Potentially confusing code has been explained with comments
- [x] No warnings or errors have been introduced; all known error cases have been handled
- [ ] Any appropriate documentation (within the code, README.md, docs, etc) has been updated
- [ ] All edge cases have been addressed
Hmm, would it be possible to edit a file and not have it come back to the working tree as "Modified"? I'm still coming across that problem that we talked about earlier where the file before it was committed and linted pops back on as "Modified"