observing / pre-commit

Automatically installs a git pre-commit script in your git repository which runs your `npm test` on pre-commit
MIT License
1.88k stars 153 forks source link

Question: Prevent pre-commit hook to continue on committing? #149

Open diegodesouza opened 4 years ago

diegodesouza commented 4 years ago

I'm trying to prevent git/vim from opening when there's a lint warning/error.

  "scripts": {
   ...
    "lint": "av lint",
   ...
  },
  "pre-commit": ["lint"],

Right now, when running git commit the pre-commit hook will run the lint, and even though there are lint errors, it won't prevent the developer from committing the work. Can you suggest a solution?

diegodesouza commented 4 years ago

@3rd-Eden @mcollina @kriskowal @alexindigo would you have a suggestion?

mcollina commented 4 years ago

I don't know what library are you using, but it's not exiting with exit code 1.

diegodesouza commented 4 years ago
{
...
  "scripts": {
    ...
    "lint": "lint",
    ...
  },
  "pre-commit": [
    "lint"
  ],
  ...

  "dependencies": {
    ...
    "prop-types": "^15.7.2",
    "react": "^16.13.1",
    "react-block-ui": "^1.3.3",
    "react-dom": "^16.13.1",
    "react-dropzone": "7.0.1",
    "react-hot-loader": "^4.12.20",
    "react-hot-loader-loader": "0.0.7",
    "react-html-parser": "^2.0.2",
    "react-input-mask": "^2.0.4",
    "react-router-dom": "^5.1.2",
    "reactstrap": "^8.0.0",
    "save": "^2.4.0",
    "tus-js-client": "^1.8.0",
    "uuid": "^7.0.3"
  },
  "devDependencies": {
   ...
    "chai": "^4.2.0",
    "cross-env": "^5.0.5",
    "enzyme": "^3.11.0",
    "husky": "^4.2.5",
    "lint-staged": "^10.1.6",
    "moxios": "^0.4.0",
    "pre-commit": "^1.2.2",
    "prettier": "^1.19.1",
    "react-test-renderer": "^16.13.1",
    "sinon": "^7.3.2",
    "sinon-chai": "^3.5.0"
  }
}
diegodesouza commented 4 years ago

@mcollina my fault there's my package.json

diegodesouza commented 4 years ago

I have also tried --bailOnLintError true without avail