Hello, question...in an Angular project, how can you execute the scripts defined in package.json in a git hook? For example, if you define in .lintstagedrc { "src/**/*.{ts,html}": "npm run lint" } and in package.json the script "lint": "ng lint", it does not recognize the command
@@MonsterlessonsAcademy My question is if in an Angular project it is possible from lint-staged to run the scripts defined in package.json. I couldn't achieve this.
Nice one mate! So, am I right it understanding that the pre-commit is primarily for fail-on-linting attempt (eslint) & not for formatting? Because any formatting write by prettier when git commit would be unstaged.
I have an issue - when i run "npx lint-staged" i have only one tasks call but if i do the same with pre-commit hook which calles the same "npx lint-staged" i have too many callings of tasks (50+), wdyt about this issue?, i cant imagine what is going wrong...
Hi, nice tutorial! Do I push the .husky-folder to the repository to ensure that other developers can use pre-commit hooks automatically? Or what is the best practice for that?
Hey! Can you help me with the error given below when I run npx lint-staged. Error: > Couldn't find any `pages` or `app` directory. Please create one under the project root at findPagesDir (C:\Users\momin.hayat\Desktop\ops-2-next ode_modules ext\dist\lib\find-pages-dir.js:42:15) "lint-staged": { "src/**/*.{js,html,css}": "prettier --write", "src/**/*.{ts,tsx}": "next lint" } and my folder structure is following src/app/*
WATCH NEXT: Javascript Interview Questions and Answers - Dominate Your Next Interview - ua-cam.com/video/wnYKH2dO620/v-deo.htmlsi=5DfbGEfhXWiiv0a_
Thank you so much for post the requested video. We want a video with Angular project.
I will add it to the list of ideas
amazing explanation, thanks. Very high quality content, keep going bro
Glad you liked it!
For anyone watching this video: Remember not to install eslint, lint-staged, husky and prettier as dependencies but as devDependencies instead.
You are totally right but only if people install later packages for prod only.
one more good Oleksandr's lesson
Thank you!
Great explanation, thanks 👍👍
Glad it was helpful!
Do we need them in dependency? I think we can install them as devDependancy right? The official documentation says so.
dev dependency is better
Thank you Sir ! clean & short ♥you earn my sub
Welcome!
Hello, question...in an Angular project, how can you execute the scripts defined in package.json in a git hook? For example, if you define in .lintstagedrc { "src/**/*.{ts,html}": "npm run lint" } and in package.json the script "lint": "ng lint", it does not recognize the command
Unfortunately I don't help with debugging custom problems in UA-cam comments.
@@MonsterlessonsAcademy My question is if in an Angular project it is possible from lint-staged to run the scripts defined in package.json. I couldn't achieve this.
Nice one mate! So, am I right it understanding that the pre-commit is primarily for fail-on-linting attempt (eslint) & not for formatting? Because any formatting write by prettier when git commit would be unstaged.
Prettier is fine as well as a check but not as an autoformat as it will make files unstaged.
@@MonsterlessonsAcademy Thank you!
it worked
As expected!
I have an issue - when i run "npx lint-staged" i have only one tasks call but if i do the same with pre-commit hook which calles the same "npx lint-staged" i have too many callings of tasks (50+), wdyt about this issue?, i cant imagine what is going wrong...
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,json,css,md,yml,yaml}": [
"prettier --write"
],
"src/**/*.{js,jsx,ts,tsx}": [
"eslint --max-warnings=0"
]
},
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged
I'm sorry I never had such issue.
thanks bro
Welcome
Amazing video 😄😄
Thanks 😁
Hi, nice tutorial! Do I push the .husky-folder to the repository to ensure that other developers can use pre-commit hooks automatically? Or what is the best practice for that?
If you want the same behaivour for everybody then yes you push it.
do you still need these setups when the code automatically formatt and prettify itself when ctrl + s??
Yes sure. You ctrl + s just calls prettier
@@MonsterlessonsAcademy So, I don’t need to set all these up, right?
jetbrains IDEs have that in pre commit settings integrated already, don't they?
Maybe but the idea is to install pre commit hooks automatically on the machine of every developer and not be dependent on IDE.
@@MonsterlessonsAcademy Oh yes right, now i get your point!
Hey! Can you help me with the error given below when I run npx lint-staged.
Error: > Couldn't find any `pages` or `app` directory. Please create one under the project root
at findPagesDir (C:\Users\momin.hayat\Desktop\ops-2-next
ode_modules
ext\dist\lib\find-pages-dir.js:42:15)
"lint-staged": {
"src/**/*.{js,html,css}": "prettier --write",
"src/**/*.{ts,tsx}": "next lint"
}
and my folder structure is following
src/app/*
Unfortunately I don't help with debugging custom code
Nice tutorial would have been nice if it was angular specific.
My next video will be exactly about Typescript and Eslint
@Miguel A Thanks will check it out.