0

I have installed husky to use it as a pre commit git hook. I am also using lint-staged. My package.json has following scripts:

  "lint-staged": {
    "src/**/*.{ts,tsx,css,md,json}": "yarn run format",
    "*.{ts,tsx}": "yarn run lint:fix"
  },
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "lint": "eslint . --ext 'src/**/*.{js,jsx,ts,tsx,json}' --report-unused-disable-directives --max-warnings 0",
    "lint:fix": "eslint --fix 'src/**/*.{js,jsx,ts,tsx,json}'",
    "format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc.json",
    "preview": "vite preview",
    "prepare": "husky install"
  },

The problem I have is that if I do a change in 2 files, for example file A has some staged changes that are failing some lint rule, and file B has some changes that are not staged. On running git commit, I get a linting error for the file A, and the commit fails, but all the changes in the file B are lost. How can I fix this, what is wrong in this setup?

Leff
  • 1,968
  • 24
  • 97
  • 201

0 Answers0