-
Notifications
You must be signed in to change notification settings - Fork 64
Replace Husky and lint-staged with pre-commit #1862
Conversation
Storybook and Tailwind configuration previews: Ready Storybook: https://wordpress.github.io/openverse-frontend/_preview/1862 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
Size Change: -1.97 kB (0%) Total Size: 814 kB
ℹ️ View Unchanged
|
Weirdly Prettier is suggesting a number of strange changes to the codebase that are purely stylistic and weren't being suggested before. If someone can checkout the branch locally to see why Prettier is suggesting extra changes, that'd be very helpful. |
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 am loving this PR. I made a small suggestion for the ignore paths. So excited to re-review this once it's undrafted 🥳
@@ -0,0 +1,114 @@ | |||
exclude: Pipfile\.lock|migrations|\.idea|node_modules |
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.
There might be more files than this to ignore as well, but I think we need at least these 🤔
exclude: Pipfile\.lock|migrations|\.idea|node_modules | |
exclude: pnpm-lock\.yaml|\.idea|node_modules|nuxt-template-overrides|\.storybook |
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.
@sarayourfriend I added an exception for nuxt-template-overrides
in ESLint. Even without excluding the others, all checks are passing. So I think it's better to leave them in.
I got some missing package errors in the IDE and when linting:
|
@obulat IDE linting will generally not work with this PR because tooling like Prettier and ESLint will not be installed as Node modules. This might be a huge drawback for this approach. |
We can leave the dependencies in as development dependencies anyway. It'll mean updating them in two places but we already have to update dependencies in this repository by hand anyway due to the pnpm limitations. |
@dhruvkb what's blocking here? |
I am facing some problems in getting Node tooling to work reliably inside the I haven't had time to debug what's behind that yet. No blockers, just been busy with some other work. |
@zackkrida this seems to be working now! @sarayourfriend I've left the Node dependencies unchanged so that IDE integration works. As a next step, we should uninstall Husky and lint-staged Node packages, but I'm thinking to do that in a separate because |
Sounds good to me to do the package.json changes in a fast-follow PR. Nice job getting this working 🚀 |
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.
It works great, nice to have consistency across all the repos!
I've left a lot of questions, but none are blocking.
Co-authored-by: Olga Bulat <obulat@gmail.com>
@dhruvkb observing some local error output: front on pre_commit +/- [$] via v16.15.0
❯ pnpm dev
> openverse-frontend@2.2.1 predev /Users/zackkrida/Code/openverse/front
> pnpm install && pnpm i18n:no-get
Lockfile is up-to-date, resolution step is skipped
Already up-to-date
> openverse-frontend@2.2.1 prepare /Users/zackkrida/Code/openverse/front
> pnpm pc:download && pnpm pc:install
> openverse-frontend@2.2.1 pc:download /Users/zackkrida/Code/openverse/front
> curl https://api.github.com/repos/pre-commit/pre-commit/releases/latest | grep -o 'https://.*\.pyz' -m 1 | xargs | xargs curl -fsJo pre-commit.pyz -L
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6175 100 6175 0 0 27703 0 --:--:-- --:--:-- --:--:-- 28456
> openverse-frontend@2.2.1 pc:install /Users/zackkrida/Code/openverse/front
> python3 pre-commit.pyz install -t pre-push -t pre-commit
[ERROR] Cowardly refusing to install hooks with `core.hooksPath` set.
hint: `git config --unset-all core.hooksPath`
ELIFECYCLE Command failed with exit code 1.
ELIFECYCLE Command failed with exit code 1.
ELIFECYCLE Command failed with exit code 1. |
Gotta run |
@dhruvkb will do. Should we document that somewhere for contributors then? |
Yeah, I'll update the contributor docs. Should I do that in a separate PR? |
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.
LGTM. The git config --unset-all core.hooksPath
is not necessary by default, if I understand correctly, so it might be fine to just send a slack notice to existing frontend contributors and not actually add information directly to the repo documentation.
Fixes
Fixes #1641 by @sarayourfriend
Description
This PR replaces Husky and lint-staged with the tried-and-tested pre-commit that we're already using in all other repos.
This PR
pc:*
scripts to thepackage.json
file to download, install and run pre-commiti18n
,types
,test:unit
)Screenshots
See how the
test:unit
hook is skipped during the pre-commit staged but run during pre-push stage.Testing Instructions
git config --unset core.hooksPath
test:unit
hook runs.Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin