2

I want to check the staged files with linter on commit. And that's how I configured package.json

  "scripts": {
     ...
    "lint": "eslint .",
    "lint:ts": "eslint . --ext .ts --ext .tsx",
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "src/**/*.{ts,tsx}": [
      "yarn run lint:ts"
    ]
  },

But it seems like husky doesn't run the pre-commit hook. Nothing happens on commit. But if I run the yarn run lint:ts manually then it works as expected.

I searched the Internet for solutions. And the one with installing husky v4 first and then updating it didn't work. How do I do?

scripter2021
  • 341
  • 2
  • 10

0 Answers0