From the course: Angular: Workflows

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Configuring commit hooks with Husky

Configuring commit hooks with Husky - Angular Tutorial

From the course: Angular: Workflows

Start my 1-month free trial

Configuring commit hooks with Husky

- [Instructor] Let's take a look now at how we can provide gateway checks when committing our code. Commit hooks are a great way to run certain checks to ensure clean code and provide a great way to prevent bad commit whether that is code that fails to pass linting, desired formatting, or even a failing test suite. Husky can be used to easily configure git hooks. It's an npm package so let's install it. In our terminal, we run npm install -D husky. Once it's installed, we can go ahead and configure a precommit hook in our package.json by simply adding a precommit npm script. Let's add precommit here and for our precommit script, we just want to run our linter, npm run lint, which will then in turn run ng lint. Let's test this by making a change. Head over to the hacker-detail.component and let's remove the implements OnInit. Now because I have the TSLint plugin for VS Code, my editor is telling me of this error. But let's say I try to commit this file, git add git commit adding…

Contents