TLDR: Here's the repo I setup where is everything for you to check out.
For my new project (more news soon) I need it to setup a monorepo (M O N O R E P O) and I wanted to check some tooling in order to validate and check multiple things before pushing to Github.
What I found out was that in order to setup
husky correctly, it needs to be installed only in teh root of the project. If you have both tools installed on each package, it will not run when you commit. Thanks to yarn workspaces, I can still run my pre commit scripts on each package from the root, al automated using husky and lint-stages. Here's how:
yarn add lint-staged husky --ignore-workspace-root-check(you need the
--ignore-workspace-root-checkflag so the packages will be installed in the root of the project)
package.jsonfile or with separate rc files:
.lintstagedrc). You can see more about these tools on their own repos
lintas my pre commit script.
lintscript in the root's
yarn workspaces run lint.
lint-staged will run the root's
lint script, and Yarn workspaces will run each package
lint script using the
yarn workspaces run lint command.