Amazing video!! I was just wondering if it's possible to connect a '.prettierrc.json' file to the 'prettier --write .' command. I assumed this would happen automatically but in my case it didn't.
if it's in the root of the project, it _should_ pick that up automatically: prettier.io/docs/en/configuration.html you can also set the config path manually: prettier.io/docs/en/cli#--find-config-path-and---config
Hey mate, commiting does not format my code automatically ;( running separately yarn format does. What can be the problem? "scripts": { "lint": "prettier --check .", "format": "prettier --write ." }, "husky": { "hooks": { "pre-commit": "yarn format && -A ." }
hey the newer version of husky uses a different syntax so that may be the issue. here's my code example for the version in the video: github.com/colbyfayock/my-husky-project/blob/main/package.json
This tutorial is great 🚀, I tried it with husky v8 but it was not working it will only work with husky@^4.3.0 . or it can be like I am missing something while working with husky version 8 🙌
@@colbyfayock The documentation on their GitHub is very sparse. Thankfully, I managed to find their actual latest documentation that's quite more on depth after posting my initial comment. A lot of it is rooted in using npx and just storing the hooks in a husky directory of bash scripts that you commit into the repo.
@@colbyfayock I can't accurately say -- at least not in comparison to the old one -- because I only learned about Husky a month ago. Honestly, I prefer to keep the configurations in it's own dotrc file and try to keep the package.json file as clean as possible. I forgot the reasons as to why they did this; I think they mentioned something about how using config files and package.json files were too inconsistent. When you run "npx husky-init" it (assuming you're going with default settings) adds "./.husky/_/husky.sh", a hook for testing to start off with at "./.husky/pre-commit", and a gitignore in husky to make sure that the husky script doesn't get added to the repo. It also includes "prepare": "husky install" in your package.json scripts. So, as it stands now, I prefer some config file so you can more easily see and change what hooks are there. I'm sure there's a reason for this change, but I'm not fully sure why.
@@bigk9000 yeah interesting, thanks for sharing. i dont do anything crazy with mine, mostly just running formatting, i just like that i can add a few lines of config next to my existing "scripts" in there, but i could see how that would be helpful especially if you're doing more complicated tasks
Often enough, you've got files in your working tree that you don't want to stage into your current commit. In that case, `git add -A . ` in your pre-commit is going to render the husky tool a nuisance.
depends on what you're trying to do. also lint-staged can help prevent the issue you're running into, where it will automatically run git add to only the files that were originally staged upon change github.com/okonet/lint-staged#migration
Learn how to build a full stack Next.js app in my upcoming course: colbyfayock.com/course
Awesome. I learned what I needed in just 5mins. Amazing!
🙌
what a great format. clear
BONUS POINTS for warning users that package versions may increase so this config may enstale.
glad it was helpful! 🙌
Had never heard of Husky before. Interesting one. Thanks!
no problem, its super handy!
The best explanation out there!! Thanks Colby
no problem!
Wow! This is really neat. I need to learn more about tools like this!
Thanks, yeah, this helps the workflow so much, especially when dealing with teams, keeping a consistent codebase
Amazing video, Colby!
I found out about your channel few days ago and I like your videos very much! Been pretty helpful to me so far :)
thanks so much Petar!! :D
Just like he predicted in the video, for husky version 5 and above, you have to configure the git hooks way different now using husky
💯
Great tutorial. Subscribed. Love your precise and on point vids. Kudos!
thank you so much!
The video was right to the point. Thanks man.
no problem!
I'm doing a project where i need to get the output (verbose) of the pre-commit and view them in a separate window. This has helped to get the basic.
glad to hear it was helpful! 🙌
Hello, I am your latest subscriber. Thanks for the video
and thank you fort he sub :)
Thank you very much for video @colbyfayock. Could you record new extended video with combine eslint rules and prettier under husky
hey not sure if ill get to that one but i'll add it to my list!
Amazing video!! I was just wondering if it's possible to connect a '.prettierrc.json' file to the 'prettier --write .' command. I assumed this would happen automatically but in my case it didn't.
if it's in the root of the project, it _should_ pick that up automatically: prettier.io/docs/en/configuration.html
you can also set the config path manually: prettier.io/docs/en/cli#--find-config-path-and---config
Thanks!!
this is deprecated, would love to have a video on how to it with the current version of husky.
thanks for the suggestion, i'll keep that in mind!
Hey mate,
commiting does not format my code automatically ;(
running separately yarn format does. What can be the problem?
"scripts": {
"lint": "prettier --check .",
"format": "prettier --write ."
},
"husky": {
"hooks": {
"pre-commit": "yarn format && -A ."
}
hey the newer version of husky uses a different syntax so that may be the issue. here's my code example for the version in the video: github.com/colbyfayock/my-husky-project/blob/main/package.json
This tutorial is great 🚀, I tried it with husky v8 but it was not working it will only work with husky@^4.3.0 .
or it can be like I am missing something while working with husky version 8 🙌
thanks, yeah! this is only 4.3 unfortunately as they completely redid how it works
For some reason, "husky install" doesn't add the hooks listed in the package.json file.
hm i think that might be a newer version of husky, haven't played around with that version yet. id try checking out the docs github.com/typicode/husky
@@colbyfayock The documentation on their GitHub is very sparse. Thankfully, I managed to find their actual latest documentation that's quite more on depth after posting my initial comment.
A lot of it is rooted in using npx and just storing the hooks in a husky directory of bash scripts that you commit into the repo.
@@bigk9000 ah. what do you think of that newer API? i tend to like the idea of my husky scripts being managed in package.json... 🤔
@@colbyfayock I can't accurately say -- at least not in comparison to the old one -- because I only learned about Husky a month ago.
Honestly, I prefer to keep the configurations in it's own dotrc file and try to keep the package.json file as clean as possible.
I forgot the reasons as to why they did this; I think they mentioned something about how using config files and package.json files were too inconsistent.
When you run "npx husky-init" it (assuming you're going with default settings) adds "./.husky/_/husky.sh", a hook for testing to start off with at "./.husky/pre-commit", and a gitignore in husky to make sure that the husky script doesn't get added to the repo.
It also includes "prepare": "husky install" in your package.json scripts.
So, as it stands now, I prefer some config file so you can more easily see and change what hooks are there. I'm sure there's a reason for this change, but I'm not fully sure why.
@@bigk9000 yeah interesting, thanks for sharing. i dont do anything crazy with mine, mostly just running formatting, i just like that i can add a few lines of config next to my existing "scripts" in there, but i could see how that would be helpful especially if you're doing more complicated tasks
Often enough, you've got files in your working tree that you don't want to stage into your current commit. In that case, `git add -A . ` in your pre-commit is going to render the husky tool a nuisance.
depends on what you're trying to do. also lint-staged can help prevent the issue you're running into, where it will automatically run git add to only the files that were originally staged upon change github.com/okonet/lint-staged#migration
Get fresh tutorials and other free content straight to your inbox! colbyfayock.com/news
👏👏👏👏👏
🙌
great
thanks!
Чётко), но очень быстро объясняешь, как будто кто-то подганяет).
not totally sure what you mean!
Super mudge
haven't heard this one, what's "mudge"?
bro, you are going very fast..
thanks for the feedback!
Adjust the audio speed =]
I love his speed.