Introducing git-validate

Maintaining code quality is hard. That's why a little over two years ago, I created precommit-hook to help automate things like linting and running tests.

Over the years, precommit-hook has evolved, but it's always had the same basic functionality. Run a simple npm i --save-dev precommit-hook and the module takes care of the rest. It's worked great for a long time, and been adopted by quite a few people. So then what's the problem?

Customization. If you want to change the behavior of the hook, you have to either fork it and make the changes yourself and publish a new module, or you have to make manual changes to your project's package.json. For a module with the goal of making things as simple as possible, that's kind of a bummer.

Enter git-validate. The idea behind git-validate isn't to automatically do all the things for you, but rather to provide a very simple framework for creating your own modules that do as much or as little as you want them to.

Using git-validate, you essentially gain the ability to create a template for your projects. For an example of this, I have ported precommit-hook to leverage git-validate to give you an idea of how it will work. The install file is where all the magic happens.

No more assumptions are made about what linter you use, what scripts you want to run, or what files you want included in your project when the module is installed. You have absolute control. The pre-commit hook isn't even created unless you create it. Have a script you want to run on pre-push? Go ahead! Add a Validate.installHooks('pre-push'); to your module's install script, add the "pre-push" key to your .validate.json and you're done!

With git-validate my hope is to see a ton of inventive new ways that people are maintaining their code quality. Create your own module and send me a link (I'm @quitlahok on twitter); I'd love to see what you're are doing with it.

(NOTE: as of the writing of this blog post, git-validate is at version 0.1.0. That means it's not completely finished. Linux and OS X support is functionally complete, but Windows support needs some work. If you use Windows, I would recommend waiting for the 1.0.0 release, which should be coming in the next few days.)

Hey there! Want more cool stuff from the &yet team? Then why not sign up for our mailing list? It's chock-full of vitamin G (for goodies).

You might also enjoy reading:

Blog Archives: