I have the following package.json
:
"scripts": {
"lint": "npm run v2:lint",
"v2:lint": "cd ./v2 && npm run lint && cd .."
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js, json}": "npm run lint"
}
However when I actually did a commit, I can see:
npm ERR! [email protected] lint: `npm run v2:lint "C:/dev/codes/my-app/v2/app/index.js"`
As we can see, the file path is appended to the end but I didn't ask it to do so. Why is lint-staged do this?
Had the same problem, took me a while to realize. The whole idea of lint-staged is that you can use it to run linting or whatever commands you want ONLY ON STAGED FILES. So what it does is appends them to your command. Basically expect your commands to be run like this (example with prettier):
So while usually you would add some path to the end like this
Simply remove the path at the end and let the lint-staged provide the paths.