lint-staged: Lint staged not working, no error, no warning
I followed this example https://github.com/okonet/lint-staged#installation-and-setup
Have this in my package.json
"scripts": {
"pre-commit": "lint-staged"
},
and added this to my .lintstagedrc file
{
"*.css": "stylelint",
"*.scss": "stylelint --syntax=scss"
}
Latest OSX, Node version v6.10.0 and npm version 3.10.10
I had stylelint installed already and my stylelint works fine if I run via my grunt task. grunt stylelint
I made a change to my existing .scss file but don’t get anything in CLI when I add files to staging and commit. Things just work like there is no lint-staged.
Edited
I followed this article https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8
// package.json
...
"scripts" {
"lint-staged": "lint-staged",
"stylelint-staged": "stylelint --syntax scss"
},
"lint-staged": {
"*.js": "eslint",
"*.scss": "stylelint-staged"
},
"pre-commit": "lint-staged"
...
and it worked but I get this warning too after linting errors
pre-commit:
pre-commit: We've failed to pass the specified git pre-commit hooks as the `lint-staged`
pre-commit: hook returned an exit code (1). If you're feeling adventurous you can
pre-commit: skip the git pre-commit hooks by adding the following flags to your commit:
pre-commit:
pre-commit: git commit -n (or --no-verify)
pre-commit:
pre-commit: This is ill-advised since the commit is broken.
pre-commit:
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 9
- Comments: 22
I ran
rm -rf node_modulesandnpm installagain. after deleting.git/hooks/pre-commitfile and setup everything again from here https://github.com/okonet/lint-staged#installation-and-setupNow I’m back to this error again https://github.com/okonet/lint-staged/issues/165#issuecomment-301003092
After a brief moment of clarity and looking at
index.js, I realized I didn’t have"lint-staged": "lint-staged"in mypackage.jsonwhich silently failsindex.js:228for me. I apologize for the false alarm in my case.i ran
npm cibecause I couldn’t get lint-staged to work either. On re-install i saw a message in terminal:So i ran
git --version. I am on 2.9. So I updated git to 2.23 and rannpm ciagain with a successful install.now when I try to commit files my lint-staged hook runs and I see errors as expected.
No, just choose one. pre-commit don’t have uninstall scripts so you have to clean it up before installing husky probably.
Hmm, the error you’re seeing seem to be in my code. Checking.
Not sure what’s going on but I’d recommend cleaning up the
.git/hooksdirectory — remove all actually hooks (withoutsample),rm -rf node_modulesand do a newnpm install.@okonet Do we need to use
huskyandpre-commitboth?I uninstalled
pre-commitand installedhuskyand getting this error