My project folder is setup with two subfoders, frontend
and backend
to house codes respectively.
Therefore in the root folder I have:
- backend
- package.json
- other backend codes
- frontend
- package.json
- other frontend codes
- package.json
In the root's package.json, I have:
"scripts": {
"frontend:lint": "cd ./frontend && npm run lint && cd ..",
"backend:lint": "cd ./backend && npm run lint && cd .."
},
"devDependencies": {
"husky": "4.3.8",
"lint-staged": "10.5.3"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"frontend/**/*.{ts, tsx, json, html}": [
"npm run frontend:lint"
],
"backend/**/*.{ts, json}": [
"npm run backend:lint"
]
}
However if I do git add
and the git commit
on root level, it keeps saying No staged files match any configured task.
I have looked into both of the sub package.json and they all worked. I am not sure how to configure lint-staged to filter files.