apiaryio / dredd

Language-agnostic HTTP API Testing Tool
https://dredd.org
MIT License
4.17k stars 278 forks source link

Add linting to Git hooks #1321

Open artem-zakharchenko opened 5 years ago

artem-zakharchenko commented 5 years ago

I propose to add various linting tools we use as a part of Git workflow.

Why:

How:

  1. Use husky for pre-commit hook to perform eslint.
    1. Alternatively, use lint-staged to eslint and prettify code.
  2. Use husky for pre-push hook to use commitlint to validate commits.
honzajavorek commented 5 years ago

I agree the CI should fail fast, or somehow signalize that the lint is failing fast, otherwise one waits 15 minutes until realizing a commit needs to be fixed or a semicolon is missing.

If the hooks are shared using husky, I'd be cautious about pre-commit with eslint as that could break my workflow when prototyping or committing work in progress often, but I'd be fine with having it in pre-push for sure.

Currently that can be achieved locally using a following workaround:

$ echo "npm run lint" > .git/hooks/pre-push
$ chmod +x .git/hooks/pre-push

I'll try to use that for a start before we make permanent change and have husky as an additional dependency.

honzajavorek commented 4 years ago

@artem-zakharchenko Can we close this now? Is everything in place?