Thanks for the tutorial! Definitely learning here I'm trying to understanding something.. lint-staged package is necessary because it can lint and fix only the files we are about to commit (files in in the stage area), correct? Not sure if we get another benefit from installing it. I tried running just with husky like this: "husky": { "hooks": { "pre-commit": "npm run lint:fix" } }, but with this way the formatting for the js files was done after the commit was completed so it didn't work as I expected. also tried: "pre-commit": "npm run lint:fix; git add ." but this way it adds everything for the commit (and I may have other files that I actually didn't want to add to the commit)
I have an array with "npm run lint:fix" and "git add" (without the period), and it works like charm. See the repo github.com/alex996/react-css-spinners/blob/master/package.json
Thanks for the amazing playlist :). One quick question when I commit husky and lint-staged doesnt seem to be working. The terminal shows: husky > pre-commit (node v10.16.0) No staged files match any of provided globs. My package.json file is identical to yours (as is my folder structure) "scripts": { "lint": "eslint '**/*.js'", "lint:fix": "prettier-eslint '**/*.js' --write" }, "husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "*.js": [ "npm run lint:fix", "git add" ] } Thanks for your help :)
Ignore files in lint-staged? It takes a glob pattern, so you could include/exclude with it. Otherwise, with ESLint, you just create a .eslintignore file
This might be a really stupid question. But if you can simply use git-hooks to run all your tests before commits, what is the point of having a CI?? You simply enforce this in your team and no need for a slow and costly CI build...
Git hooks will run on the staged files, not on the entire codebase. The point of CI is to catch typos or errors before they into production typically by running a linter and/or formatter and a test suite. Developers can still bypass or disable git hooks when pushing; they also often forget to re-run the tests. CI is kind of a gateway that shields your live servers from bad code.
Great video, clear and concise... could you made a 2021 updated versión? ... Thanks for sharing
Man this series is god mode. Thanks for this
This is a great tutorial series, kindly also finish the MERN + Graphql series. Thanks!
Thanks for the tutorial! Definitely learning here
I'm trying to understanding something.. lint-staged package is necessary because it can lint and fix only the files we are about to commit (files in in the stage area), correct? Not sure if we get another benefit from installing it.
I tried running just with husky like this:
"husky": {
"hooks": {
"pre-commit": "npm run lint:fix"
}
},
but with this way the formatting for the js files was done after the commit was completed so it didn't work as I expected.
also tried:
"pre-commit": "npm run lint:fix; git add ."
but this way it adds everything for the commit (and I may have other files that I actually didn't want to add to the commit)
I have an array with "npm run lint:fix" and "git add" (without the period), and it works like charm. See the repo github.com/alex996/react-css-spinners/blob/master/package.json
Aren't the pre and post hooks of git itself enough in npm-scripts? Should we use husky?
Possibly, although I haven't used Git hooks. I suppose husky uses them under the hood.
well explained thanks
Thanks for the amazing playlist :). One quick question when I commit husky and lint-staged doesnt seem to be working. The terminal shows:
husky > pre-commit (node v10.16.0)
No staged files match any of provided globs.
My package.json file is identical to yours (as is my folder structure)
"scripts": {
"lint": "eslint '**/*.js'",
"lint:fix": "prettier-eslint '**/*.js' --write"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"npm run lint:fix",
"git add"
]
}
Thanks for your help :)
Is there a way to ignore files? the "ignore" key is deprecated and i micromatch.not doesnt work :( is there an example for it
Ignore files in lint-staged? It takes a glob pattern, so you could include/exclude with it. Otherwise, with ESLint, you just create a .eslintignore file
Great series. 👍
This might be a really stupid question. But if you can simply use git-hooks to run all your tests before commits, what is the point of having a CI?? You simply enforce this in your team and no need for a slow and costly CI build...
Git hooks will run on the staged files, not on the entire codebase. The point of CI is to catch typos or errors before they into production typically by running a linter and/or formatter and a test suite. Developers can still bypass or disable git hooks when pushing; they also often forget to re-run the tests. CI is kind of a gateway that shields your live servers from bad code.
Nyc as always
It's not working don't know why