How to prevent inaccessible code from making it to your site using Tenon and Husky

Today I added a new branch to the grunt-tenon-demo repository on GitHub to show how to use Tenon as a Git Hook, using Husky.

Personally, I find Git’s own documentation on Git hooks to be woefully inadequate. Fortunately there are some good tutorials out there for creating Git hooks. In some cases, Git hooks don’t need to be complicated. Fortunately, for those cases, there’s Husky. Using Tenon is one of those times.

Step-by-step adding Tenon as a Git hook

The first step is to install Husky by running npm install husky --save-dev

Next, all you need to do is add the relevant command to your package.json file. For example:

This hook will prevent any code from being pushed to your repository if it doesn’t pass Tenon’s tests. Errors, if any, will be output to terminal.

Naturally you don’t need to use Grunt for this. You can use Gulp or any of the many other packages that use Tenon, including CLI.

By far, the best way to manage accessibility is to avoid problems in the first place. This is one of the easiest ways to do so.

Post a Comment