Skip to content
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

Improvements to our commit-hook (lint-staged) #3433

Closed
4 tasks
arikfr opened this issue Feb 13, 2019 · 16 comments · Fixed by #4435
Closed
4 tasks

Improvements to our commit-hook (lint-staged) #3433

arikfr opened this issue Feb 13, 2019 · 16 comments · Fixed by #4435

Comments

@arikfr
Copy link
Member

arikfr commented Feb 13, 2019

  • Switch to using prettier-eslint for linting and formatting files along with calling git add when done.
  • Run Prettier on CSS/Less files as well.
  • Make sure the messaging about what's going on is clear, as it might be confusing to new developers.
  • Run flake8 when the developer using our Docker setup
@ranbena
Copy link
Contributor

ranbena commented Feb 13, 2019

You mean git add cause you wanna run it with --fix?

@jezdez
Copy link
Member

jezdez commented Feb 13, 2019

To echo my question in #3390 (comment), can we add a kill switch to all of these hooks to optionally disable it?

@ranbena
Copy link
Contributor

ranbena commented Feb 13, 2019

Other than -n?

@jezdez
Copy link
Member

jezdez commented Feb 13, 2019

@ranbena Yes.

@ranbena
Copy link
Contributor

ranbena commented Feb 13, 2019

I think you can just remove the relevant files from .git/hooks.

@jezdez
Copy link
Member

jezdez commented Feb 13, 2019

Would that have to happen on individual npm install runs?

@ranbena
Copy link
Contributor

ranbena commented Feb 13, 2019

Indeed. Every husky install would bring em back.

@arikfr
Copy link
Member Author

arikfr commented Feb 13, 2019

Indeed. Every husky install would bring em back.

That's not a solution :-)

Although I'm not sure if having a solution that permanently disables this makes sense. 🤔 It's either we think it's necessary or we don't.

@arikfr
Copy link
Member Author

arikfr commented Feb 13, 2019

@ranbena btw, how about we run tests only on push and linting on commit? Linting should be fast on a few files and almost a no-op, while tests are a bit heavier.

@jezdez
Copy link
Member

jezdez commented Feb 13, 2019

There is the HUSKY_SKIP_INSTALL env var that when set during installation prevents the hooks to auto-installed in the .git directory.

There is the node husky uninstall command that uninstalls the hooks.

Both things don't really prevent this from persisting between runs of npm install.

@ranbena
Copy link
Contributor

ranbena commented Feb 13, 2019

not sure if having a solution that permanently disables this makes sense.

Since it's overridable anyhow, I don't see a problem with allowing devs to disable it comfortably. If there's a technical way I'd be happy to review such a PR.

we run tests only on push

It's a trade-off. On pre-push the full suite would have to be run which is a waste.

@jezdez
Copy link
Member

jezdez commented Feb 13, 2019

Indeed. Every husky install would bring em back.

That's not a solution :-)

Although I'm not sure if having a solution that permanently disables this makes sense. 🤔 It's either we think it's necessary or we don't.

I couldn't find an explanation in #3390 why this commit hook is necessary to be honest. Could you elaborate what the advantages are?

@arikfr
Copy link
Member Author

arikfr commented Feb 13, 2019

@ranbena,

Since it's overridable anyhow, I don't see a problem with allowing devs to disable it comfortably. If there's a technical way I'd be happy to review such a PR.

The problem is one of the message it sends: it's either we think it's important or we don't. If we don't, then we can just provide instructions to how to setup hooks for whoever interested instead.

@jezdez,

I couldn't find an explanation in #3390 why this commit hook is necessary to be honest.

  1. To make sure we get consistent code in terms of formatting (helps with reviews later on).
  2. Provides earlier feedback to the developer about lint errors. It's not uncommon to see lint errors ignored. If the feedback provided early in the process (or fixed automatically) it's easier to handle.

@jezdez
Copy link
Member

jezdez commented Mar 5, 2019

FWIW, to reiterate what I said before: it would be great to have this hook not auto-installed and/or a way disable it easily. And no, remembering how to disable commit validation/verification on every commit isn't enough.

An example for how this breaks things for me, a screenshot of the Tower Git app that I use to commit things when I want to split changes up into individual commits or have to handle the rebases of our fork:

screen-shot-2019-03-05-13-12-38 51

@ranbena
Copy link
Contributor

ranbena commented Mar 5, 2019

An example for how this breaks things for me, a screenshot of the Tower Git app

Yeah Tower Git has issues with hooks. Have you tried mitigating this?

@jezdez
Copy link
Member

jezdez commented Mar 5, 2019

An example for how this breaks things for me, a screenshot of the Tower Git app

Yeah Tower Git has issues with hooks. Have you tried mitigating this?

This isn't really an issue Tower has, it simply uses a PATH environment variable without the local node_modules directory. I don't think it's reasonable to having to maintain a custom, global plist file just to be able to commit to this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants