1

I have a sample web project which has client and server, so before commit any files I have added husky to make the formatting changes, when I add it as script it works but when I do git add . and git commit its showing as

No staged files match any configured task.

What am I doing wrong here.

client package.json

 "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --write"
    ]
  },
  "devDependencies": {
    "husky": "^4.3.8",
    "lint-staged": "^12.3.1",
    "prettier": "^2.5.1",
  }

server package.json

   "husky": {
        "hooks": {
          "pre-commit": "lint-staged"
        }
      },
      "lint-staged": {
        "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
          "prettier --write"
        ]
      },
      "devDependencies": {
        "husky": "^4.3.8",
        "lint-staged": "^12.3.1",
        "prettier": "^2.5.1",
      }

What am I doing here wrong, any help is appreciated

torek
  • 448,244
  • 59
  • 642
  • 775
dev
  • 814
  • 10
  • 27

1 Answers1

0

Check first if, as in typicode/husky issue 767, a npm rebuild is needed.

Double-check also the installation process to see if a simple npm test, for instance, would work (npx husky add .husky/pre-commit "npm test")

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I have checked the npm rebuild but that didn't done anything, same issue. So what I done added some changes, then npm rebuild then git add . , then git commit but still same No staged files match any configured task. – dev Jan 27 '22 at 20:08
  • Is it because of client and server folder my project structure is application inside two folders client (react) and server (node js) – dev Jan 27 '22 at 20:09
  • @dev Possible. I would start from a simper project, just to test if the commit hook works there, before adding back elements of your current project structure. – VonC Jan 27 '22 at 20:51
  • @VonC I feel like there is no need for this comment, and I'm sorry if so but I'm trying to pass you in the weekly leaderboard :P – Sarout Jan 27 '22 at 20:54
  • @Sarout No problem. Passing me in any leaderboard is good for the community: more high quality answers benefit everyone. – VonC Jan 27 '22 at 20:58
  • yeah, I've liked helping others in this community in my week off, but passing you in all-time's leaderboard is like trying to cut the earth 8 pieces... – Sarout Jan 27 '22 at 21:02