NWACus / avy

Mobile-Native Viewing of NAC Avalanche Forecasts
MIT License
10 stars 6 forks source link

Add pre-commit hooks for linting/prettier #680

Open kevindice opened 6 months ago

kevindice commented 6 months ago

After opening #678, I noticed it failed because the new json file didn't conform to prettier formatting rules. We can avoid the hassle here by setting up a pre-commit hook that auto-fixes these issues. With husky + commit-lint, we can also make this take significantly less time by only checking the changed files rather than all files. (Running yarn prettify on my machine takes > 30 seconds.)

Let's set up husky and commit-lint to autofix this trivial stuff in a pre-commit so that contributors never have to think about it.

stevekuznetsov commented 6 months ago

@kevindice great idea! Have you used Biome or any of the new-age tooling for formatting? It would be awesome if we could get 90%+ of the benefit and have it run in one hundredth the time as well.

kevindice commented 6 months ago

I've not - eslint tends to have such a strong ecosystem presence for substantive rules like the react-hooks stuff. For style though, it's definitely up for switching around. In practice, eslint/prettier runs pretty fast on changed files for any reasonable commit size. Here, speed isn't my main concern, it's more about reducing friction for frequent activities like commiting so we never getting a red X because of a misplaced comma.

stevekuznetsov commented 6 months ago

Gotcha - even the diff-based invocation (I think the default in JetBrains editor on save) is hilariously slow compared to what I am used to outside of JS ecosystem but I'll buy "fast enough" :)

yuliadub commented 6 months ago

I'm in for pre-hook commits. I ended up setting them on one of my machines but if I try to do anything from my laptop it ends up being a pain :D