-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add husky pre-commit hook, add lint-staged #8013
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few reservations about adding Husky to the project, where it runs arbitrary code on each git
command. Namely:
- I don't want to be required to have to set
HUSKY_SKIP_INSTALL
to prevent arbitrary code running on each Git command. (i.e. I don't want this to be opt-out.) - I see each dependency we add to the project as a liability. A dependency that intentionally runs arbitrary code as a very large liability.
I would be open to, instead of Husky, adding a prominent note the the README.md
about how a user can opt-in to having a hook installed. e.g. cp development/hooks/pre-commit .git/hooks/pre-commit
.
On lint-staged
: I'm cool with it. Can we move the config to a .lintstagedrc
file? I don't quite want the package.json
to become a collection of configs.
My thinking here is that we're already using this in However, I think when it comes to new contributors on-boarding, having something like this is a big help. re: opt-out: I don't think it's that hard to append |
This seems heavy-handed—why would I want to "bypasses the pre-commit and commit-msg hooks" permanently? What if I have custom personal hooks installed? Or hooks in a different repo? I think this is a classic opt-in vs. opt-out debate, and I think as a security & privacy-focused product we should be extremely intentional about what we require opt-out for, and I think requiring users to opt-out of arbitrary code execution is a no-go. I understand that this could be/is useful for some devs, but I don't see a way to make this remotely secure. |
I mean... I don't understand why you would not want to lint your JavaScript before pushing it to a remote only to discover the build broke there? If we're really concerned about this from a security stand point perhaps we should consider removing it from the mobile repo? |
This doesn't need to exist for me to be able to run
I want to make space for other devs to chime in here, but I would't be opposed it. As another alternative, we could update the git config core.hooksPath ./development/hooks
yarn
yarn start This approach is opt-in, and still allows us to update the hooks with the repository without requiring users to rerun a command. |
closing this to implement what was discussed here in a separate PR |
This gives us a pre-commit hook via husky and lint-staged similar to what we do in
metamask-mobile