-1

Here is my pre-commit file code which I have taken from https://gist.github.com/linhmtran168/2286aeafe747e78f53bf but every time it returns same COMMIT SUCCEEDED.

Here is the linting failure picture linting failure picture

ng lint having an issue but still how It can succeed. It should return validation fail message and commit should not be done but struggling with it.

Please will be much appreciated

I seen Adding precommit hooks with Husky without pushing addition to git but not so helpfull.

Neha Shah
  • 1,147
  • 6
  • 14

1 Answers1

-1

The linked gist has a bug: it uses #!/bin/sh as the shebang but it uses bash syntax if [[ "$STAGED_FILES" = "" ]]. To fix the bug change the shell to bash:

#!/bin/bash

or

#!/usr/bin/env bash

Also my advice is to add set -e at the beginning so the shell fails at every error:

#!/usr/bin/env bash
set -e
phd
  • 82,685
  • 13
  • 120
  • 165
  • I tried all above solution but then there is no any reflection of that file seems all goes like before when there was not pre-commit file. please assist. and there is code STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$") so should i change .jsx to .ts ? – Neha Shah Mar 13 '20 at 05:25