3

I have configured lint-staged as following in my Angular 7 app.

  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "linters": {
      "*.ts": "ng lint --fix my-app --files"
    },
    "relative": true
  },

I am using Intellij idea. When I am committing files in the editor, it runs husky. If there are any errors, it fixes them but commits the old files and not the ones which got changed after "ng lint --fix " and I have to commit the changed files again.

Basically I want the changed files to be committed after it executes "ng lint --fix" and not the old ones.

Any help on how to resolve this issue?

Ansuman
  • 1,404
  • 4
  • 14
  • 32

1 Answers1

1

Are you saying that committing from command-line works fine, but commuting from IDE does not?

In fact, it looks like the pre-commit hook does not stage files after running ng lint --fix. In this case, though, committing from the command line will not commit linter modifications as well.

Make sure the hook calls git add after applying linters.

Dmitrii Smirnov
  • 7,073
  • 1
  • 19
  • 29