Make Sure You’re Not Committing Bad JavaScript by Using a Git Hook

As a follow on to my post about using a Git hook with PHP Code Sniffer to make sure that you’re committing good PHP code, this post is going to cover doing the same thing to make sure that your JavaScript passing a JSLint check.

The only pre-requisite to get this to work is to install JSLint using npm. Install npm and then run  npm install jslint in your project root folder.

A now the .git/hook/pre-commit code

You will want to make sure that the path to JSLink is correct on line 7. If you want to change what files get checked, you can change the extensions in line 9.

Code source:

Leave a Reply