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

Remove husky as a requirement? #11

Closed
DoctorDerek opened this issue Mar 31, 2021 · 3 comments · Fixed by #23
Closed

Remove husky as a requirement? #11

DoctorDerek opened this issue Mar 31, 2021 · 3 comments · Fixed by #23

Comments

@DoctorDerek
Copy link
Contributor

DoctorDerek commented Mar 31, 2021

Hey @timlrx ,
Do you think it's better to include instructions on using husky or to remove it as a dependency?

I went to commit locally after cloning the template, but I couldn't because husky not being configured threw an error.

That meant I had to pause what I was doing to npm uninstall husky -- then commit the package.json & package-lock.json files -- and then commit my actual changes.

I'm happy to update your template for whichever solution you think is best.

@timlrx
Copy link
Owner

timlrx commented Apr 1, 2021

Hi Derek,

Husky is a pre-commit hook to ensure that new code committed runs through prettier and eslint. I guess you were having some eslint errors? If so, the solution is to fix it, then recommit. Or use --no-verify as an escape hatch.

Would still prefer it to be there for the template, but I can understand users opting to remove them for their own repos. Let me know what problem you ran into and I will see whether I can replicate / fix it.

@DoctorDerek
Copy link
Contributor Author

Hi Tim,
Bumping this. I don't get it?

image

I mean, sure, I get it -- but isn't the appropriate place for this type of hook to be in some type of automation after the pull request?

I'll submit a PR that will let me not have ESLint errors...
--> They're caused by not having a .gitattributes file when I'm a Windows developer, so every single file in the PR has a ESLint error on every line, see tailwindlabs/tailwindcss#3760

But fundamentally husky seems like an odd dependency, given that it forces someone to use the command line -- at least if they're a Windows developer like myself using GitHub Desktop. I'm one of those developers who thinks the GUI (GitHub Desktop) is a better choice and never commit from the command line except in case of emergency.

The error is related to "cygpath" not being found (because GitHub Desktop doesn't know what that means); the ESLint errors get auto-fixed by running husky:
image

Anyway, I'll close the issue since you're keeping the dependency. No worries.

@DoctorDerek
Copy link
Contributor Author

Just to follow up in case anybody stumbles on this in Google, GitHub Desktop will work with husky as configured, but only if you've already done npm install (so husky is in PATH locally).

There were previously various bugs (on both macOS and GitHub Desktop) with husky not working, but pre-commit hooks like @timlrx has set up for https://github.com/timlrx/tailwind-nextjs-starter-blog/ will work fine:
package.json

  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.+(js|jsx|ts|tsx)": [
      "eslint --fix"
    ],
    "*.+(js|jsx|ts|tsx|json|css|md|mdx)": [
      "prettier --write"
    ]
  }

Cheers!

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.

2 participants